多表关联,显示列名问题
有A表结构如下
aid col1
1 "A"
2 "B"
3 "C"
4 "BD"
B表结构
bid tbA_aid nameb
1 1 "bbbb1"
C表结构
cid tbA_aid namec
1 2 "cccc1"
D表结构
did tbA_aid named
1 3 "dddd1"
2 4 "dddd2"
B、C、D表的tbA_aid都是表A的外键,即A关联着B\C\D着几个表,要查询的机构是:
aid name
1 "bbbb1"
2 "cccc1"
3 "dddd1"
4 "dddd2"
请问SQL语句怎么写?谢谢
------解决方案--------------------
SQL code
select tbA_aid nameb from B
union all
select tbA_aid nameb from C
union all
select tbA_aid nameb from D