有人可以帮助我在访问中创建3个表的完全连接吗? thriD join将介于我的BB table& CC在位置。
SELECT *
FROM AA
JOIN BB ON AA.C_ID = BB.C_ID
UNION ALL
SELECT *
FROM AA
LEFT JOIN BB ON AA.C_ID = BB.C_ID
WHERE BB.C_ID IS NULL
UNION ALL
SELECT *
FROM AA
RIGHT JOIN BB ON AA.C_ID = BB.C_ID
WHERE AA.C_ID IS NULL
谢谢
答案 0 :(得分:0)
我还没有测试过以下代码,但我相信这个想法是使用第三个表重复另一个完整的连接:
SELECT * FROM AA
LEFT JOIN BB ON AA.C_ID = BB.C_ID
WHERE BB.C_ID IS NULL
UNION ALL
SELECT *
FROM AA
RIGHT JOIN BB ON AA.C_ID = BB.C_ID
WHERE AA.C_ID IS NULL
UNION ALL
SELECT * FROM CC
LEFT JOIN AA ON AA.C_ID = CC.C_ID
WHERE CC.C_ID IS NULL
UNION ALL
SELECT *
FROM AA
RIGHT JOIN CC ON AA.C_ID = CC.C_ID
WHERE AA.C_ID IS NULL