select o.*
from order_info o
where o.user_id in(
    select user_id
    from order_info
    where datediff(date,'2025-10-15')>0
    and product_name in ('C++','Python','Java')
    and status='completed'
    group by user_id
    having count(*)>1
) 
and datediff(o.date,'2025-10-15')>0
and o.product_name in ('C++','Python','Java')
and o.status='completed'
order by o.id
  • 选出符合条件的用户id
  • 记得要重新筛选一遍