Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个表,其中一些列是常见的。我想加入这些表并形成第三个表,这是两个表的组合。例子:
Table 1
ABCDEF
Table 2
ABCGHI
预期输出:
Table 3
ABCDEFGHI
谁能建议我如何做到这一点?
您可以使用 join 进行此操作。
CREATE TABLE table3 AS SELECT t1.A, t1.B, t1.C, t1.D, t1.E, t1.F, t2.G, t2.H, t2.I FROM Table1 t1 LEFT JOIN Table2 t2 ON t1.A = t2.A AND t1.B = t2.B AND t1.C = t2.C
如果要创建新表,此查询将为您提供 ABCDEFGHI 输出