Joins
Learn SQL joins with practical examples and guided drills on dbSyntax.
Start with Joins IntroJoins Intro
BeginnerThis subsection gives you a practical foundation before detailed join syntax. Goal: understand what joins do, which join to pick, and how to...
INNER JOIN
BeginnerINNER JOIN keeps rows where the join key matches in both tables. If a row has no partner on the other side, it is dropped, from both sides. ...
LEFT JOIN
BeginnerLEFT JOIN keeps every row from the left table, even when no match exists on the right. Unmatched right-side columns come back as NULL. This ...
RIGHT JOIN
BeginnerRIGHT JOIN keeps every row from the right table and fills left-side columns with NULL when there's no match. It's the mirror image of LEFT J...
FULL OUTER JOIN
BeginnerFULL OUTER JOIN keeps every row from both tables. Where there's a match on the join key, columns from both sides come through. Where there i...
CROSS JOIN
BeginnerCROSS JOIN returns every combination of rows from two tables: the Cartesian product. No ON clause, no matching key. If table A has n rows an...
Self Join
BeginnerA self join is any join where both sides are the same table. You use it to relate rows within a single entity: employees to their managers, ...
Join Debugging: Duplicates & Missing Rows
BeginnerAlmost every join bug in production shows up as one of two symptoms: 1. The row count ballooned. Your SUM is suddenly double, your COUNT is ...
UNION vs UNION ALL
BeginnerEvery join in this section combined tables side-by-side: each output row got wider as columns from both tables lined up on a key. Set operat...