Return all rows from both tables, matching where possible.
The FULL JOIN (or FULL OUTER JOIN) returns all rows from both the left and right tables. Where a match exists based on the join condition, the row contains data from both tables. Where no match exists, the missing side is filled with NULL values. FULL JOIN combines the behavior of LEFT JOIN and RIGHT JOIN. It is useful for reconciliation tasks, identifying mismatches between datasets, or any scenario where you need a complete picture of data from both tables regardless of matches.
| Name | Description | Optional |
|---|---|---|
left_table |
The first table, from which all rows are returned. | No |
right_table |
The second table, from which all rows are returned. | No |
condition |
The join condition that specifies how the tables are related, using ON. | No |
SELECT a.name, b.name FROM table_a a FULL JOIN table_b b ON a.id = b.a_id;
SELECT e.name, d.department_name FROM employees e FULL JOIN departments d ON e.dept_id = d.id;