分组查询,获取每组前三条数据,时间倒序

(select `id` from table where uid = 2 order by createtime desc limit 3) UNION ALL 

(select `id` from table where uid = 3 order by createtime desc limit 3) UNION ALL 

(select `id` from table where uid = 7 order by createtime desc limit 3) UNION ALL 

(select `id` from table where uid = 11 order by createtime desc limit 3) UNION ALL 

(select `id` from table where uid = 14 order by createtime desc limit 3) UNION ALL 

(select `id` from table where uid = 24 order by createtime desc limit 3) 

暂无评论

发布评论