2017-04-01 26 views
0

一個查詢(3臺)比方說,我有3個表,我想加入他們這樣的:如何讓2個不同的加入了關於MySQL的

table 1 join table 2 and table 2 join table 3 

我想下面的代碼,但我」 m出現語法錯誤。

SELECT * from table1 join table2 and table2 join table3 on table1.id=table2.idA and table2.idB=table3.id

回答

3

研究了在SQL一點。語法是這樣的:

select * 
from table1 join 
    table2 
    on table1.id = table2.idA join 
    table3 
    on table2.idB = table3.id; 

這是非常基本的JOIN語法,應在任何教程,文檔,書籍,紙張或任何你正在使用學習SQL覆蓋。