# 查询这些用户id的订单信息并连接client表以获得字段name
select t1.id, is_group_buy, name client_name
from (
select id, is_group_buy, client_id
from order_info
where user_id in (
# 先查询满足条件的用户id
select user_id
from order_info
where datediff(`date`, '2025-10-15') > 0
and status = 'completed'
and product_name in ('C++', 'Java', 'Python')
group by user_id
having count(*) > 1
)
and datediff(`date`, '2025-10-15') > 0
and status = 'completed'
and product_name in ('C++', 'Java', 'Python')
) t1
join (
select * from client
union
select 0, Null
) t2
on t1.client_id = t2.id
order by t1.id;