I'm trying to accomplish a Full Outer Join with my SQL.
- FULL (OUTER) JOIN: Return all records when there is a match in either left or right table
Although apparently this is not supported. I've looked around and have come across this accepted answer: https://stackoverflow.com/a/4796911/3859456
SELECT * FROM t1
LEFT JOIN t2 ON t1.id = t2.id
UNION
SELECT * FROM t1
RIGHT JOIN t2 ON t1.id = t2.id
Although won't this at least repeat the matched records twice when we do a Union? If not does a union automatically overwrite the matched records to the 2 tables?
E.g.
LEFT (OUTER) JOIN: Return all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Return all records from the right table, and the matched records from the left table
Union Left-Outer-Table + (left-matched = right-matched)x2 + Right-Outer-Table
I'm sure the answer works as the community trust it. But I'm still confused as to how it works and hope that someone can help me understand better.