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

(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) 

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-BlogPHP 1.5.2 Zero

 Theme By 优美尚品

Copyright Your WebSite.Some Rights Reserved.