FULL JOIN (often written as FULL OUTER JOIN or just FULL) is one of the ANSI-standard join types. It combines the effects of LEFT JOIN and RIGHT JOIN in a single operation. The database engine scans both input tables, produces pairs of rows that satisfy the join condition, and also retains any rows that do not find a match in the opposite table. For those non-matching rows, the columns that come from the missing side are filled with NULL values. If multiple rows satisfy the join predicate, the result contains a Cartesian combination of those rows, just like INNER or LEFT/RIGHT joins. Some vendors require the keyword OUTER while others accept FULL alone. Because NULLs appear whenever a side lacks a match, downstream filters or aggregations must be NULL-aware. FULL joins can be expensive on large tables because the engine must materialize and sort unmatched rows from both sides. Indexes on the join columns mitigate cost.
table1
(table) - First input tabletable2
(table) - Second input tableON condition
(expression) - Boolean predicate that defines matching rowsINNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN, USING, NATURAL JOIN, UNION
SQL-92
FULL JOIN can be resource intensive because the database must collect unmatched rows from both tables. Indexes on join columns and proper statistics help, but large, unfiltered FULL JOINs may require significant memory and disk I/O.
Combine a LEFT JOIN and a RIGHT JOIN with UNION ALL, then filter duplicates:```SELECT * FROM a LEFT JOIN b ON a.id = b.idUNION ALLSELECT * FROM a RIGHT JOIN b ON a.id = b.idWHERE a.id IS NULL;```
Yes, if both tables contain the column(s) referenced. Example:```SELECT *FROM table1FULL JOIN table2 USING (id);```
Check for NULLs in columns from either side. Example:```SELECT *FROM a FULL JOIN b ON a.id = b.idWHERE a.id IS NULL OR b.id IS NULL;```