LEFT JOIN

A join that keeps every row of the left table and adds the matching right-hand rows, or NULLs when there is no match.

In more detail

Its result is the inner join plus the unmatched left rows. Count a right-hand column such as COUNT(o.id), not COUNT(*), or an unmatched row counts as one. A WHERE condition on the right table removes the NULL rows and turns it back into an inner join, so put such conditions in ON.

Example

FROM customers AS c LEFT JOIN orders AS o ON o.customer_id = c.id

Related terms

Taught in

References