SQL FULL JOIN
FULL OUTER JOIN keeps every row from both sides. Rows with no match get NULL on the missing side.
Example
SQL
SELECT c.name, o.total FROM customers c FULL OUTER JOIN orders o ON o.customer_id = c.id;
What it returns
| Scenario | Appears? |
|---|---|
| Customer with orders | Yes — one row per order. |
| Customer without orders | Yes — total is NULL. |
| Order with no matching customer | Yes — name is NULL. |
Vendor support
- SQL Server, PostgreSQL, Oracle, SQLite 3.39+ — supported.
- MySQL doesn't have
FULL OUTER JOIN. Emulate it withLEFT JOIN UNION RIGHT JOIN.
MySQL workaround
SQL
SELECT c.name, o.total FROM customers c LEFT JOIN orders o ON o.customer_id = c.id UNION SELECT c.name, o.total FROM customers c RIGHT JOIN orders o ON o.customer_id = c.id;
Tip: A FULL OUTER JOIN often signals a reconciliation problem — "show me everything in either source, side by side". Common in finance, audit, and migration scripts.
Example
Example
SELECT c.name, o.total FROM customers c FULL OUTER JOIN orders o ON o.customer_id = c.id;Try it Yourself »
Exercise
Returns every row from both tables.
FULL
JOIN orders ON ...
Five letters; standard SQL keyword between FULL and JOIN.
Discussion
Loading…