表连接sql

uhry853o  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(325)

我需要加入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
kse8i1jr

kse8i1jr1#

所以我在每个选中的项目后面添加了逗号,然后当您想将它们连接在一起时需要表名。看看网上不同连接的例子。希望这能帮你/为你指明正确的方向!:)

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

相关问题