MySQL多表关联查询数量


//多表关联查询数量
select user, t1.count1, t2.count2
from user t
left join (
select user_id, count(sport_type) as count1
from sport group by user_id
) t1
on t.id = t1.user_id
left join (
select user_id, count(level) as count2
from grade group by user_id
) t2
on t.id = t2.user_id
order by t.id

posted @ 2017-03-09 16:56  今天、天气晴  阅读(9039)  评论(0编辑  收藏  举报