通过使用第三个表连接两个表来创建表
我有三个表:
表 1(770 万条记录)
ID_1|..|..|其他字段|
表 2(820 万条记录)
ID_2 |..|..|.....
表 12(750 万条记录)
ID_1| ID_2 |一些字段|
AND ID_1== ID_2.ie
包含所有常见的 id
table 12
包含常见于 id
的唯一 id
代码>表1和2
。 我正在尝试创建一个新表,通过将 t12
中的记录与 id_1,id_2< 进行匹配来获取来自
t1
和 t2
的所有数据/代码>)。
以下是我使用的sql:
CREATE TABLE ARROW_all_common12 AS
SELECT T1.*, T2.* FROM T1, T2
LEFT JOIN T12
ON T12.ID_1=T1.ID_1
LEFT JOIN T12
ON T12.ID_2 = T2.ID_2
WHERE T12.ID2 = T2.ID_2
I have three tables:
TABLE 1 (7.7million records)
ID_1|..|..| OTHER FIELDS|
TABLE 2 (8.2 million records)
ID_2 |..|..|.....
TABLE 12 (7.5 million records)
ID_1| ID_2 | SOMEFIELDS|
AND ID_1== ID_2.i.e.
contains all common ids
The table 12
contains unique ids
which are common to table 1
and 2
.
I am trying create a new table to get all data from t1
and t2
by matching which records in t12
with id_1,id_2
).
Following is the sql Iam using:
CREATE TABLE ARROW_all_common12 AS
SELECT T1.*, T2.* FROM T1, T2
LEFT JOIN T12
ON T12.ID_1=T1.ID_1
LEFT JOIN T12
ON T12.ID_2 = T2.ID_2
WHERE T12.ID2 = T2.ID_2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全确定你在这里问什么,但也许视图可能就是你正在寻找的?
I'm not entirely sure what you're asking here, but maybe a view could be what you're looking for?
一样的,不太清楚。也许是这样?
same, it's not quite clear. maybe that?