56,687
社区成员
发帖
与我相关
我的任务
分享
select a.id, (select id from b) as bid,
(select id from c) as cid,
(select id from d) as did
from A
limit 10
select a.id,u.t
from A left join (
select 'B' as t,id from B
union all
select 'C' as t,id from B
union all
select 'D' as t,id from B
) u on a.id=u.id
select a.*,if(b.aid is not null,'B',if(c.aid is not null,'C','D')) as tableName
from a
left join b on a.id=b.aid
left join c on a.id=c.aid
left join d on a.id=d.aid
order by a.id
limit 10;