Introduction to JOINs
Real databases have multiple related tables. JOINs let you combine them to get complete information.
New Tables Available
Starting this module, you have access to order-related tables:
- orders - Customer orders (user_id, order_date, total_amount, status)
- order_items - Items in each order (order_id, product_id, quantity, price)
These tables reference each other through ID columns (foreign keys).
Why JOIN?
Consider this: the orders table has user_id but not the user's name. The products table has product names but order_items only has product_id. JOINs let you combine these to answer questions like "What did Alice order?"
Basic JOIN Syntax
SELECT columns
FROM table1
JOIN table2 ON table1.column = table2.column;
The ON clause specifies how the tables relate.
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Table Aliases
Use short aliases to make JOINs more readable:
SELECT o.id, u.name
FROM orders o
JOIN users u ON o.user_id = u.id;
Free Practice
Loading SQL editor...
Try:
- Join products with categories to see category names
- Join order_items with orders to see order totals
- Experiment with different column selections

