Joins for SQLs
Joins combine rows from two or more tables based on a related column, usually a foreign key matching a primary key. INNER, LEFT, RIGHT, FULL and CROSS joins differ in which unmatched rows are kept. Subqueries, including correlated ones and EXISTS, let one query use the result of another.
Stage: Multiple Tables · Part of the SQL roadmap · Last reviewed 19 November 2026
What to learn in Joins
- Write an INNER JOIN between orders and customers using the key columns
- Use LEFT JOIN to keep unmatched rows and find them with IS NULL
- Join a table to itself to model a manager and employee hierarchy
- Rewrite an IN subquery as an EXISTS or a join
- Avoid accidental row multiplication from joining on non-unique columns
Joins interview questions
What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only rows that have a match in both tables. LEFT JOIN returns every row from the left table and fills columns from the right table with NULL where no match exists. LEFT JOIN is used to find items with no related records, like customers without orders.
How do you find rows in one table that have no match in another?
Use a LEFT JOIN and filter for NULL in the right table's key, or use NOT EXISTS with a correlated subquery. NOT EXISTS is often clearest and handles NULLs safely. Avoid NOT IN when the subquery column can contain NULL, because it can return no rows.
Where Joins fits in the SQL roadmap
Joins belongs to the Multiple Tables stage (beginner level), which takes about 18 hours. Relate data across tables.