Joins
Combine tables with INNER, LEFT and self joins without multiplying rows by accident.
What you will be able to do
- Join on indexed keys.
- Use LEFT JOIN when the right side is optional.
- Alias tables for readable SQL.
- Watch for duplicate rows when one side has many matches.
In plain English
A join matches rows from two tables on a condition. INNER keeps matches, LEFT keeps every left row, and a self join uses two aliases of the same table. Check cardinality before trusting a join.
SELECT c.title AS course, l.title AS lesson, l.minutes
FROM courses c
JOIN lessons l ON l.course_slug = c.slug
WHERE c.slug = 'css'
ORDER BY l.minutes DESC;Your turn
MediumList courses with lesson counts
Join courses to lessons and count lessons per course.
SQL · starter
SELECT c.title FROM courses cCheck your understanding before moving on.
Knowledge checkQuestion 1
Which join keeps every row from the left table?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.