Chapter 6 · Lesson 1 of 7

Why JOINs Exist

Understand why normalized data lives in separate tables and how JOINs reconnect related rows through matching key columns.

When a database is normalized, related facts live in different tables. That keeps the data clean, but it also means you need a way to bring those facts back together when you query.

That is what JOIN does. It combines rows from two tables based on a matching key.

For example, employees.department_id points to departments.id. The employees table knows which department an employee belongs to, and the departments table knows the department name. A JOIN lets you combine both facts into one result.

The most important thing in a JOIN is the matching condition:

ON employees.department_id = departments.id

If you understand which columns connect the tables, the rest of the JOIN becomes much easier to reason about.

This lesson is theory-focused. Read it, then mark it complete in the Learn SQL panel before moving on.

Open this lesson in the SQL editor

Lessons in JOIN Types

Combine related tables with INNER, LEFT, RIGHT, FULL OUTER, SELF, and CROSS JOIN, and find rows that have no match.

  1. 01 · Why JOINs Exist
  2. 02 · INNER JOIN Basics
  3. 03 · LEFT JOIN Keeps the Left Side
  4. 04 · Finding Missing Matches
  5. 05 · RIGHT JOIN and FULL OUTER JOIN
  6. 06 · SELF JOIN for Hierarchies
  7. 07 · CROSS JOIN for All Combinations

Related guides