标签:
第一种
select t1.id,
t1.name,
t1.age,
(select count(1) from b t2 where t1.id = t2.id) filecount
from a t1
第二种
select t1.id, t1.name, t1.age, t2.filecount
from a t1
left join (select id, count(1) filecount from b group by id) t2
on t1.id = t2.id
sqlserver 连接查询的问题,a表无重复记录,与b表中的记录为1对N关系,如何在查得a表信息时统计b表记录数
标签:
原文地址:http://www.cnblogs.com/wei-java/p/4540105.html