SQL INNER JOIN
Combine rows of two tables that match on a condition.
Syntax
SELECT … FROM a JOIN b ON b.key = a.key;
Only pairs that match are kept. JOIN on its own means INNER JOIN.
Example
Query (on the shop database used in the SQL course)
SELECT o.order_id, o.order_date, c.name FROM orders AS o JOIN customers AS c ON c.customer_id = o.customer_id LIMIT 5;
Result
| order_id | order_date | name |
|---|---|---|
| 1 | 2025-06-10 | Aarav Sharma |
| 2 | 2025-05-17 | Aarav Sharma |
| 3 | 2025-03-25 | Aarav Sharma |
| 4 | 2025-10-26 | Aarav Sharma |
| 5 | 2025-02-27 | Aarav Sharma |
5 rows
Related
Learn it step by step in the free lesson Joining Tables, with exercises that check your queries.