Your First JOIN
Orders with customer names.
Helen wants a list of orders, with the customer's name next to each one. The order is in one table, and the name is in another. Join brings them together.

- Orders and names, side by side
- Two different tables
- JOIN brings them together
JOIN ... ON
After from orders, we write join customers. Then on, which says how the rows match up. A customer row matches an order row when their customer IDs are equal. Because two tables now share column names, we write the table name, a dot, and the column. Run it. Every order now shows the customer's name.
SELECT orders.order_id,
orders.order_date,
customers.first_name,
customers.last_name
FROM orders
JOIN customers
ON customers.customer_id = orders.customer_id
LIMIT 4;โโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโ โ order_id โ order_date โ first_name โ last_name โ โโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโค โ 1001 โ 2025-03-06 โ Tara โ Brown โ โ 1002 โ 2024-11-24 โ Tara โ Brown โ โ 1003 โ 2024-06-22 โ Grace โ Lopez โ โ 1004 โ 2025-02-19 โ Grace โ Lopez โ โโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโ
What JOIN does
Here's what happens inside. For each order, SQL looks up the customer with the matching ID. It glues the two rows together, side by side, into one wide row. Then select picks the columns you asked for.
Summary
Join, then on, then the matching columns. That's the pattern for every join you'll ever write. Next, a way to make joins much shorter to type.
Key takeaways- JOIN another table
- ON says how rows match
- table.column avoids confusion