[ACCEPTED]-MySQL: Union of a Left Join with a Right Join-mysql

Accepted answer
Score: 10
select a.id, t1.column_1, t2.column_2
from (
    select id from t1
    select id from t2
) a
left outer join t1 on a.id = t1.id
left outer join t2 on a.id = t2.id


Score: 1

Try this one:

SELECT t1.id, t1.column_1, t2.column_2 
FROM t1 
FULL OUTER JOIN t2 ON (t1.id = t2.id)

Edit: Doesn't work, MySQL does not 1 know FULL OUTER JOIN. Have a look here: http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/

Score: 0

Haven't tried this myself, but this might 1 work:

SELECT t1.id, t1.column_1, t2.column_2, t2a.column_2
FROM t1     
LEFT JOIN t2 ON t1.id = t2.id
RIGHT JOIN t2 AS t2a ON t1.id = t2a.id

More Related questions