Lesson 18 — Three-table JOIN
Joining three tables
A many-to-many link — students take many courses, courses have many students — needs a third link table (here enrollments) holding pairs of ids. To get readable names you JOIN all three: students → enrollments → courses. Each JOIN needs its own ON.
FROM readers r
JOIN loans l ON l.reader_id = r.id
JOIN books b ON b.id = l.book_id
Why it matters: tags on posts, products in orders, users in groups — many-to-many is everywhere.
Add the second JOIN to courses so each row shows the course title. Expected: 4 rows of (student, course).
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Databases & SQL courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Databases & SQL books — check the publication year so the examples match current versions.
Search Amazon →