LEFT JOIN
ELI5 — The Vibe Check
LEFT JOIN returns all rows from the left table, and matching rows from the right table. If there is no match on the right side, you still get the left row but the right side columns are NULL. Good for 'show me all users even if they have no orders'.
Real Talk
LEFT JOIN (or LEFT OUTER JOIN) returns all rows from the left (first) table regardless of whether a matching row exists in the right table. Non-matching rows from the right table produce NULL values for its columns in the result. It is one of the most frequently used JOIN types.
Show Me The Code
-- All users, with orders if they exist
SELECT u.name, o.total
FROM users u
LEFT JOIN orders o ON u.id = o.user_id;
When You'll Hear This
"Use LEFT JOIN to get all users even if they have no orders." / "Check for NULLs on the right side to find rows with no match."
Related Terms
FULL JOIN
FULL JOIN returns everything from both tables regardless of whether there is a match. Rows with no match on either side get NULLs.
INNER JOIN
INNER JOIN only returns rows where there is a match in BOTH tables. If a user has no orders, they do not appear in the result.
JOIN
JOIN combines rows from two tables based on a related column.
RIGHT JOIN
RIGHT JOIN is LEFT JOIN's mirror image — it returns all rows from the right table, and matching rows from the left.