日期:2014-05-17 浏览次数:20451 次
select A.ID,(select count(*) from tableB B where A.ID = B.ID) from tableA A group by A.ID;
select a.id,count(b.id) from a inner join b on a.id =b.id group by a.id
------解决方案--------------------
括号里那个子查询的别名可以不用加, 难道还有比这更简洁的?
------解决方案--------------------
select a.id,count(b.id)
from a
left join b on a.id =b.id
group by a.id