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 Aleft join B on B B.b=A.aleft join C on C C.c=A.aleft join D on D D.d=A.a 就一句SQL