RIGHT JOIN &
FULL OUTER JOIN
Master two powerful SQL join types that ensure no data gets left behind: keeping all rows from the right table, or from both tables.
What Are SQL JOINs?
A JOIN combines rows from two or more tables based on a related column between them. Think of it as merging two spreadsheets using a shared key, like a student ID or order number.
The JOIN Family Visualized
Why Do These Joins Matter?
In real databases, not every row has a match. Some customers have never ordered. Some products have never been purchased. These joins ensure you see the complete picture:
The RIGHT JOIN Syntax
RIGHT JOIN in Action
The FULL OUTER JOIN Syntax
FULL OUTER JOIN in Action
LEFT JOIN vs RIGHT JOIN
They are mirror images of each other. Any RIGHT JOIN can be rewritten as a LEFT JOIN by swapping the table order:
INNER vs FULL OUTER
How to Choose Your JOIN
Example 1: RIGHT JOIN
A school has a Clubs table and a Students table. Find all students, including those not in any club:
Example 2: FULL OUTER JOIN
A store has Products and Sales tables. Find all products and all sales, even if a product was never sold or a sale references a deleted product:
Example 3: Finding Orphan Records
Use FULL OUTER JOIN with a WHERE clause to find records that exist in only one table: the orphan records.
Common Mistakes to Avoid
JOIN Types Compared
| Feature | INNER | LEFT | RIGHT | FULL OUTER |
|---|---|---|---|---|
| Matched rows | ✓ | ✓ | ✓ | ✓ |
| Unmatched left rows | ✕ | ✓ | ✕ | ✓ |
| Unmatched right rows | ✕ | ✕ | ✓ | ✓ |
| NULLs for missing data | Never | Right side | Left side | Both sides |
| Best for | Exact matches | All left + matches | All right + matches | Complete picture |
Question 1 of 5
In a RIGHT JOIN, which table's rows are guaranteed to all appear in the result?
Question 2 of 5
If Table A has 3 rows and Table B has 5 rows, and only 2 rows match on the key, how many rows does a FULL OUTER JOIN produce?
Question 3 of 5
Which SQL statement is equivalent to: SELECT * FROM A RIGHT JOIN B ON A.id = B.id?
Question 4 of 5
After a FULL OUTER JOIN, you add WHERE A.id IS NULL OR B.id IS NULL. What does this return?
Question 5 of 5
In a RIGHT JOIN result, where do NULL values appear?