Tsallaka zuwa abun ciki
Justice Tech School

Joining Three Tables

Chain joins one at a time. Each ON links the new table to a table already joined.

Example
SELECT s.name, c.title, e.enrolled_on
FROM students s JOIN enrolments e ON e.student_id = s.id
JOIN courses c ON c.id = e.course_id
WHERE c.price > 0;

Result

name   | title      | enrolled_on
Ada    | JavaScript | 2026-01-15
Kofi   | Python     | 2026-01-25
Amina  | Python     | 2026-02-05
Amina  | SQL        | 2026-02-20
Zainab | CSS Basics | 2026-03-10
Zainab | Python     | 2026-03-12

Exercise

Link the next table.

JOIN courses c  c.id = e.course_id

Quiz Test

How many ON clauses for 3 tables?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.