INNER JOIN returns only rows that have a matching record in both tables.
LEFT JOIN returns all rows from the left table, plus matching rows from the right table. If there is no match, right-side columns become NULL.
SELECT *
FROM customers c
INNER JOIN orders o
ON c.id = o.customer_id;Only customers who have orders are returned.
SELECT *
FROM customers c
LEFT JOIN orders o
ON c.id = o.customer_id;All customers are returned, including customers with no orders.
Interview shortcut:
> INNER = matching rows only > LEFT = everything from left + matches from right