34,593
社区成员
发帖
与我相关
我的任务
分享
select A1,
case when a1=1 then (select count(1) from B where id=a.id)
when a1=2 then (select count(1) from C where id=a.id)
end
from A
select a.id, if(a.a1=1,IFNULL(b.count,0),IFNULL(c.count,0)) as count
from a left join b on a.id=b.id
left jon c on a.id=c.id