Skip to content
CodeItRaw
Path

Joining tables on keys: INNER, LEFT, self joins and finding what does not match.

Key ideas

  • JOIN ... ON pairs two tables on a key; rows without a match drop out.
  • LEFT JOIN keeps every row on the left; without a match the right side is NULL.
  • Aliases (e, d) let you use the same table twice.

Pattern

SELECT e.name, d.name
FROM employees e
LEFT JOIN departments d ON d.id = e.dept_id;

Finish these first:SQL: Grouping

Lessons

Each lesson explains one idea from zero and ends with a few tasks. Lessons open in order; the explanation can be read at any time.

  1. 01

    Joining two tables

    0/2 tasks

  2. 02

    With itself, with three tables, and "those without"

    0/3 tasks

Boss

  • 03

    Project hours

    SQL query

  • The boss opens when every lesson of the topic is finished. Solve it too and the topic is complete, and the topics after it open.