select id,name,a_rankfrom table_a,(select a_id,count(*) as a_rankfrom table_bgroup by a_id)where table_a.id = table_b.a_idorder by a_rank
联合查询分为左联、内联、右联,左联:select a.xxx,b.ccc from tableA a left join tableB b on a.id=b.id
内联:select a.xxx,b.ccc from tableA a inner join tableB b on a.id=b.id
右联:select a.xxx,b.ccc from tableA a right join tableB b on a.id=b.id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)