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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM