SQL查询返回表名

2025-03-23 14:58:21
推荐回答(1个)
回答1:

select a ,
case when b IS not null then 'B'
when c IS not null then 'C'
when d IS not null then 'D' else null end
from A A
left join B on B B.b=A.a
left join C on C C.c=A.a
left join D on D D.d=A.a

就一句SQL