Skip to content

LEFT JOIN

In one line

LEFT JOIN returns every row from the left table; for rows with no match in the right table, the right columns are NULL.

In simple words

LEFT JOIN (also called LEFT OUTER JOIN) returns all rows from the left table, whether or not they have a match in the right table. When there is no match, the columns from the right table are filled with NULL.

This is useful when you want to keep all records from the left table and optionally pull in related data. For example, listing all users and their orders — users with no orders still appear, with NULL in the order columns.

LEFT JOIN is not symmetric — A LEFT JOIN B is different from B LEFT JOIN A. The "left" table is the one mentioned first (before the JOIN keyword).

Example

sql
-- All users, with their orders if any
SELECT users.name, orders.id AS order_id
FROM users
LEFT JOIN orders ON orders.user_id = users.id;
-- Users with no orders get NULL for order_id

Every user appears in the result. Users without orders have NULL for the order column.

Related terms

Related Resources

Related Lessons

  • Joins

    Learn different join types.

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary