Having you considered just using on
?
select *
from table1 join
table2
on table1.id = table2.id join
table3
on table1.ID = table3.different_ID;
質問
Can I do something as below? The reason I need to do this is because table 3 has a different column name for ID.
select *
from (table1 join table2 using(ID)) as result
join table3
on result.ID = table3.different_ID
Currently I'm having a syntax error, but my query is rather complex so I'm not sure whether this is the problem or something else.
解決
Having you considered just using on
?
select *
from table1 join
table2
on table1.id = table2.id join
table3
on table1.ID = table3.different_ID;
他のヒント
You'll need to do something like this:
SELECT *
FROM (
SELECT *
FROM table1 JOIN table2 USING (ID)
) result
JOIN table3 ON result.ID = table3.different_ID;
EDIT: Updated to reflect OP's original intent and fit OP's needs considering query complexity