17,086
社区成员
发帖
与我相关
我的任务
分享
select
t.*--主表字段,原来页面需要的字段
(select count(0) from A a where a.tid=t.tid) aNumber,--A表的外键tid等于t表的主键tid,查出A表与主表关联的记录数
(select count(0) from B b where b.tid=t.tid) bNumber,--B表的外键tid等于t表的主键tid,查出B表与主表关联的记录数
(select count(0) from C c where c.tid=t.tid) cNumber,--C表的外键tid等于t表的主键tid,查出C表与主表关联的记录数
(select count(0) from D d where d.tid=t.tid) dNumber,--D表的外键tid等于t表的主键tid,查出D表与主表关联的记录数
from main t where 条件语句