What is FULL OUTER JOIN?
FULL OUTER JOIN shows ALL rows from BOTH tables, whether they match or not.
Simple rule: Everyone is shown, matched or not!
How FULL OUTER JOIN Works
Basic Syntax
SELECT columns
FROM table1
FULL OUTER JOIN table2 ON table1.id = table2.foreign_id;Example: All Students and All Orders
SELECT students.name, orders.product
FROM students
FULL OUTER JOIN orders ON students.id = orders.student_id;Result:
- John - Books (matched)
- Mary - NULL (no order)
- Peter - NULL (no order)
- NULL - Phone (no student)
JOIN Comparison
- INNER → Only matches
- LEFT → All left + matches
- RIGHT → All right + matches
- FULL OUTER → ALL from both sides
Try It Below
Practice with pre-joined FULL OUTER JOIN results!
What Comes Next
Next: Self Join - join a table to itself!
FULL OUTER JOIN Result
Everyone shown! Peter='None' (no order), 'Unknown'=Phone (no student).
Source Table: students
| name | product | amount |
|---|---|---|
| John | Books | 50 |
| Mary | Laptop | 800 |
| Peter | None | 0 |
| Unknown | Phone | 500 |
4 rows
SQL Editor
Loading...
Filter Results
Find orders over 100. Try: SELECT name, product FROM joined_data;
Source Table: students
| name | product | amount |
|---|---|---|
| John | Books | 50 |
| Mary | Laptop | 800 |
| Peter | None | 0 |
| Unknown | Phone | 500 |
4 rows
SQL Editor
Loading...