What A Join Does
A join combines rows from two tables based on a matching condition, usually a shared key. The join type decides what happens to rows that have no match.
Inner Join
An inner join returns only rows where the condition matches on both sides. Customers with no orders simply disappear from the result. It is the strictest and most common join.
Outer Joins
Outer joins keep unmatched rows and fill the missing columns with null:
- LEFT JOIN keeps every row from the left table.
- RIGHT JOIN keeps every row from the right table.
- FULL JOIN keeps unmatched rows from both tables.
A Common Mistake
Putting a condition on the right table inside WHERE after a LEFT JOIN turns it back into an inner join, because null fails the comparison. Put that filter in the ON clause instead.
Key idea
Inner joins keep only matched rows, while left, right, and full outer joins preserve unmatched rows from one or both tables using null.