Skip to content
Justice Tech School

INNER JOIN in Practice

INNER JOIN keeps rows with a match in both tables. Qualify columns with table aliases.

Example
SELECT s.name, c.title
FROM enrolments e
JOIN students s ON s.id = e.student_id
JOIN courses c ON c.id = e.course_id
ORDER BY s.name;

Result

name   | title
Ada    | Intro to HTML
Ada    | JavaScript
Amina  | Python
Amina  | SQL
Kofi   | Python
Tunde  | Intro to HTML
Zainab | CSS Basics
Zainab | Python

Exercise

Join condition keyword.

JOIN b  a.id = b.a_id

Quiz Test

What does INNER JOIN drop?

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