SQL Joins
A SQL join combines rows from two or more tables based on a related column, usually a primary key and a foreign key. Joins let you query data that normalization has split across tables.
INNER JOIN returns only rows that match in both tables. LEFT JOIN returns all rows from the left table plus matching rows from the right (NULL where there is no match), and RIGHT JOIN does the opposite. FULL OUTER JOIN returns all rows from both tables, and CROSS JOIN returns every combination of rows.
SELECT c.name, o.id AS order_id, o.total
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id;
-- every customer, with their orders (NULL if they have none)