Hi,
how do I make a join of 1 table on 2 different tables with the same identifier ?
Table1 : id, other_id;
table2 : id, name
table3 : id, title
So table 1 on table2 and on table 3 with other_id to id.
Join 1 table on 2 different tables
Re: Join 1 table on 2 different tables
You can work with a sub-query an UNION:
Code: Select all
SELECT table1.id,union_table.name FROM table1 LEFT JOIN
(SELECT id,name FROM table2 UNION SELECT id,title AS name FROM table3)
AS union_table ON table1.other_id=union_table.id;