查询一些用户的首笔订单:
select a.* from tb_order as a right join
(select user_id, min(create_time) as maxtime from tb_order where user_id in(111,222,333) group by user_id) as b
on a.user_id=b.user_id and a.create_time = b.maxtime;
用如下验证,和上述sql结果匹配
select * FROM tb_order where user_id in (111) order by create_time asc limit(1);
select * FROM tb_order where user_id in (222) order by create_time asc limit(1);
select * FROM tb_order where user_id in (333) order by create_time asc limit(1);