Combining tables — understanding what rows each join type keeps and drops
The difference between INNER, LEFT, and FULL OUTER joins determines which rows appear in your result, and getting it wrong produces silent data loss — you get a result with no error, just missing rows. Understanding the NULL pattern that LEFT JOIN produces is essential for finding unmatched records, a very common analytics task.
Think of a join as overlapping two tables on a common key. INNER JOIN keeps only the overlap. LEFT JOIN keeps everything from the left table and fills with NULL where there's no match on the right. FULL OUTER JOIN keeps everything from both sides, NULLs on whichever side has no match.
The NULL-filling behaviour of LEFT JOIN is actually useful — filtering WHERE right_table.id IS NULL after a LEFT JOIN is the idiomatic way to find rows that exist in the left table but have no match in the right.
Joins don't have to be on equality. Range joins and inequality joins are less common but appear in problems involving overlapping date ranges and bracket lookups.