27,579
社区成员
发帖
与我相关
我的任务
分享
select * from
(
select (select orgname from org as og where org.id=og.id),
(select count(*) from tb1 as t1 whree t1.id=org.id) as number1,
(select count(*) from tb2 as t2 whree t2.id=org.id) as number2,
(select count(*) from tb3 as t3 whree t3.id=org.id) as number3,
(select count(*) from tb4 as t4 whree t4.id=org.id) as number4,
(select count(*) from tb5 as t5 whree t5.id=org.id) as number5
from org as org,tb as tb where org.id=tb.id
group by org.name having count(*)>0
) A
where number1+number2+number3+number4+number5<>0