我需要加入4个不同的表。我以前曾经做过一个全为零的联合,但这给问题带来了麻烦。 1,2和3是我要聚合数据集的方式,它们是每个表所共有的。 我现在正在做联接,但是却收到“重复表别名”错误。 有什么想法吗?
谢谢!
SELECT
A.1
A.2
A.3
A.4
B.5
C.6
D.7
FROM A
LEFT JOIN
ON A.1 = B.1
AND A.2 = B.2
AND A.3 = B.3
LEFT JOIN
ON A.1 = C.1
AND A.2 = C.2
AND A.3 = C.3
LEFT JOIN
ON A.1 = D.1
AND A.2 = D.2
AND A.3 = D.3
答案 0 :(得分:1)
因此,我添加的是每个选定项目后的逗号,然后在要将它们连接在一起时需要表名称。在线查看不同联接的示例。希望这可以帮助/指出正确的方向! :)
SELECT
A.1,
A.2,
A.3,
A.4,
B.5,
C.6,
D.7
FROM A
LEFT JOIN B
ON A.1 = B.1
AND A.2 = B.2
AND A.3 = B.3
LEFT JOIN C
ON A.1 = C.1
AND A.2 = C.2
AND A.3 = C.3
LEFT JOIN D
ON A.1 = D.1
AND A.2 = D.2
AND A.3 = D.3