第一种
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
时间: 2024-11-08 03:23:38