← SQL tutorial

SQL

JOIN

Real databases split data across multiple tables that reference each other. A JOIN combines rows from two tables based on a matching column.

Example: joining students to their track's start date

SELECT students.name, tracks.start_date
FROM students
JOIN tracks ON students.track = tracks.name;
name  | start_date
Ada   | 2026-09-01
Chidi | 2026-10-15
Musa  | 2026-09-01

Here, a separate tracks table stores each track's cohort start date once; the JOIN matches each student's track value to the corresponding row in tracks, combining data from both tables into one result. This is the entire reason relational databases split data across multiple tables in the first place — instead of repeating "Frontend starts 2026-09-01" in every single student row (and risking them drifting out of sync if that date ever changes), it's stored once and joined in whenever it's actually needed.

Example
SELECT students.name, tracks.start_date
FROM students
JOIN tracks ON students.track = tracks.name;
Output
name  | start_date
Ada   | 2026-09-01
Chidi | 2026-10-15
Musa  | 2026-09-01