Joins
Learn SQL joins with practical examples and guided drills on dbSyntax.
Start with JoinsJoins
Combine rows from two tables on a matching condition. The shape (left/right/inner/outer/cross) decides what happens to rows with no match. T...
INNER JOIN
Keep only rows with a match on both sides; rows without a counterpart disappear. It's the default join people reach for, and the one that qu...
LEFT JOIN
Preserve every row on the left, even when the right side has no match: null-fill the right-side columns. Most analytics queries that want "u...
RIGHT JOIN
Mirror of LEFT JOIN: preserves every row from the right-side table. In practice, almost never used: a RIGHT JOIN b reads more naturally as b...
FULL OUTER JOIN
Keep every row from both sides, matching where possible and NULL-filling the gaps. The shape you reach for when both sides are sources of tr...
CROSS JOIN
Every row on the left combined with every row on the right, n × m rows out. Almost never the join you want by accident, but essential when y...