Guided Notes

Joins

Combining tables with INNER, LEFT, RIGHT, and CROSS joins, joining three tables, and self joins.

Why join

Slide 1 / 5

Relational databases split data into tables to avoid repetition — an order stores customer_id, not the customer's name and city. A JOIN puts the pieces back together:

SELECT o.order_id, c.first_name, o.order_date FROM orders AS o JOIN customers AS c ON o.customer_id = c.customer_id;

The ON clause says which columns match. JOIN on its own means INNER JOIN.

← LIKE, IN, BETWEEN & Aliases