[英]How to Inner join two anonymous tables [SQL]
as the title states, Let's say i have three tables: person
, autos
, numbers
.正如标题所述,假设我有三个表:
person
, autos
, numbers
。
Created已创建
First table
with: INNER JOIN
of person
and autos
First table
有: INNER JOIN
的person
与autos
Second Table
with: INNER JOIN
of autos
and numbers
Second Table
: autos
和numbers
INNER JOIN
Question: Is it possible to INNER JOIN
first
and second
table
?问题:是否可以
INNER JOIN
first
和second
table
?
You can join the two tables based on the autos
part.您可以根据
autos
部分连接两个表。 Assuming it has an ID:假设它有一个ID:
SELECT *
FROM first_table f
JOIN second_table s ON f.auto_id = s.auto_id
You can do 2 joins (with 3 tables) together.您可以一起进行 2 个连接(使用 3 个表)。 Which are the keys for the joins?
哪些是连接的键?
personID
for person
and autos
and on numbers
person
和autos
以及numbers
personID
SELECT *
FROM person p
JOIN autos a ON p.keyA= a.keyA
JOIN numbers n ON a.keyB = n.keyB
Where keyA
and keyB
are the corresponding field on which you want to do the join.其中
keyA
和keyB
是您要进行连接的相应字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.