Joins combine tables. The type decides what happens to rows with no match.
Direct answer
INNER JOIN returns only rows that match in both tables. LEFT JOIN returns every row from the left table and fills in NULL for the right table when there is no match. Use a left join to find things like customers who have not ordered.
Example tables
customers: id, name
orders: id, customer_id, total
INNER JOIN
SELECT c.name, o.total
FROM customers c
INNER JOIN orders o ON o.customer_id = c.id;
Only customers with orders appear.
LEFT JOIN
SELECT c.name, o.total
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id;
All customers appear. Those without orders show NULL for total.
Find customers with no orders
SELECT c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.id IS NULL;
Summary
| Join | Returns |
|---|---|
INNER | matches only |
LEFT | all left rows plus matches |
RIGHT | all right rows plus matches |
FULL | all rows from both |
Where Teyro fits
Teyro's SQL and Databases for Beginners course turns this into short lessons you can play in a few minutes a day. It has 50 lessons, and you can start free.
The bottom line
Picture two circles. Inner is the overlap. Left is the left circle with its overlap.


