PostgreSQL · Joins & aggregations
A join matches row pairs
An INNER JOIN combines a row from the left input with each row from the right input for which
the ON condition is true. Rows without a match on either side do not appear in the result.
SELECT c.email, o.id AS order_id
FROM customers AS c
JOIN orders AS o ON o.customer_id = c.id;The join condition usually compares a foreign key to a primary key. State that relationship explicitly; an omitted or incorrect condition can create far more row pairs than expected.