SELECT u.user_id,u.user_name,c.ct,sub.cts FROM `zdh_users` u
LEFT JOIN (select admin_id,count(*) as ct FROM `zdh_users` GROUP by admin_id) as c
ON u.user_id = c.admin_id
LEFT JOIN (select admin_id,count(*) as cts FROM `zdh_users` where is_subscribe = 1 GROUP by admin_id) as sub
ON u.user_id = sub.admin_id
WHERE c.ct >0
order by c.ct DESC ,sub.cts DESC,u.user_id ASC
@import url(http://www.cppblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted on 2016-09-08 18:12
聂文龙 阅读(861)
评论(0) 编辑 收藏 引用 所属分类:
Database