INNER and OUTER Joins

Lesson 10 of 20

Two tables, one answer — watch INNER JOIN link matching rows, and see what LEFT JOIN would do with the leftovers.

The big picture

Why tables live apart

Copying the same course name onto every student row would waste space and invite typos. Databases split data into tables and stitch them back together with JOINs.

One fact, one place

Students live in one table, courses in another. Nothing is duplicated between them.

Foreign key

A column like course_id points at a row in another table. It is the thread that connects them.

JOIN stitches

JOIN reads two tables at once and combines matching rows into single result rows.

INNER JOIN

Keeps only pairs that match on both sides. Unmatched rows are left out.

LEFT JOIN (outer)

Keeps every row of the left table — unmatched ones get NULL in the right-side columns.