strawquery PT
All lessons

Lesson 16 of 30

INNER JOIN

Today at the studio

Nagi stares at a result: "director_id 3. Who is 3?" Information lives in several tables, and numbers mean nothing to humans. Kou's note on the monitor finally makes sense: "JOIN is the whole point."

The idea

A JOIN puts rows of two tables side by side when a condition says they belong together. Usually one table keeps the id of a row in the other table: shows.director_id points to staff.id.

FROM shows JOIN staff ON shows.director_id = staff.id pairs every show with its director. Write table.column whenever two tables share a column name. JOIN alone means INNER JOIN: rows without a match are dropped.

Example

SELECT characters.name, shows.genre
FROM characters
INNER JOIN shows ON characters.show_id = shows.id

Your turn

0 of 4 questions

Question 1 of 4

Show each show's title with the name of its director.

Unofficial fan project. Titles belong to their creators and rights holders.