Top SQL Joins Interview Questions You Need to Know
Estimated study time: 49 minutes. The join questions interviewers ask most often, answered clearly.
Joins are the single most-tested SQL topic in interviews, because they show whether a candidate can think in terms of relationships between tables. Here are the questions that come up again and again.
Q1: 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, filling in NULL for any columns from the right table that don't have a match.
Q2: What does a SELF JOIN do?
A self join joins a table to itself, typically used to compare rows within the same table — like finding employees who report to the same manager.
SELECT e1.name AS employee, e2.name AS manager FROM employees e1 JOIN employees e2 ON e1.manager_id = e2.employee_id;
Q3: What is a CROSS JOIN?
A CROSS JOIN returns the Cartesian product of two tables — every row from the first table paired with every row from the second — and should be used deliberately, since it can produce very large result sets.
Q4: Can you JOIN more than two tables?
Yes. You can chain as many joins as needed in a single query, as long as each join clause specifies a valid relationship.
SELECT o.order_id, c.name, p.product_name FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN products p ON o.product_id = p.product_id;
Q5: What's the difference between WHERE and ON in a JOIN?
ON defines the join condition itself; WHERE filters the combined result afterward. This distinction matters most with outer joins, where filtering in the wrong clause changes which rows are kept.