Joining tables
Good databases do not repeat information. An order does not store the customer's name; it stores the customer's id, which points at a row in customers:
| orders.id | customer_id | product_id | quantity | order_date |
|---|---|---|---|---|
| 4 | 3 | 4 | 1 | 2025-02-01 |
Customer 3 is Ana; product 4 is the Desk. A column like customer_id that points at another table's id is called a foreign key.
JOIN puts the pieces back together:
SELECT orders.id, customers.name, orders.quantity
FROM orders
JOIN customers ON customers.id = orders.customer_id;
ON says how rows match: an order belongs with the customer whose id equals its customer_id. Because both tables have columns called id and name, write table.column to say which one you mean.
Several joins and short names
You can join as many tables as you need. Short aliases keep queries readable:
SELECT o.id, c.name AS customer, p.name AS product
FROM orders AS o
JOIN customers AS c ON c.id = o.customer_id
JOIN products AS p ON p.id = o.product_id;
Dates are stored as text like '2025-02-20', so LIKE '2025-02%' matches every day in February 2025.
Your task
List the orders placed in February 2025, showing the order id, the customer's name as customer and the product's name as product, in order of order id.