Español

For teachers · 50 minutes

← Ready-to-teach lessons

JOIN and LEFT JOIN lesson

Joining two tables and finding what's missing in 50 minutes, closing with a real detective case. With a printable worksheet.

Goal

Every student can join two tables on their key, knows which rows JOIN drops and finds the unmatched ones with LEFT JOIN.

Lesson plan

0–5 minIntroduce the topic on the board with one example query.
5–20 minArcade, in pairs or alone. Arcade world 3: The Bridge, On Foot, The Garage and the boss, The Ghost Car.
20–35 minWorksheet: six questions on the same tables.
35–45 minCase: Case 01, "The File Nobody Asked For": two tables and a time window. It's the natural way to close the topic.
45–50 minClass discussion with the questions below. Whoever beat the boss hands in their certificate code.

Materials

SQL arcadeArcade world 3: The Bridge, On Foot, The Garage and the boss, The Ghost Car. Open the caseCase 01, "The File Nobody Asked For": two tables and a time window. It's the natural way to close the topic.

Mistakes you'll see

For the class discussion

Evidence

When a student beats a boss, the arcade gives a certificate with a code. Ask for it as the submission and check it here: check codes →

Student worksheet

Ready to print, no answers.

Worksheet PDF
SQL ARCADE
Name: ______________________________Date: ____________

JOIN and LEFT JOIN lesson

suspects
idnameagecityjob
1Lucía Prado34Lumen Bayphotographer
2Joel Ibarra52Salt Harborlocksmith
3Marta Solís27Lumen Baynurse
4Iker Vela41San Cirotaxi driver
5Rocío Andrade63Salt Harborjeweler
6Damián Cuevas19San Cirocourier
7Elena Ruiz46Lumen Bayaccountant
8Bruno Paz38Salt Harbormechanic
thefts
idsuspect_idcityloot
12Salt Harbor1200
22Salt Harbor800
34San Ciro300
45Salt Harbor5000
58Salt Harbor450
68Lumen Bay950
78San Ciro150
81Lumen Bay2200
9NULLLumen Bay700
  1. The suspect's name and the loot of each theft.
  2. The name and loot of the thefts committed in Salt Harbor.
  3. The total loot of each suspect with thefts.
  4. All suspects with the loot of their thefts, including those with none.
  5. The name of the suspects with no thefts.
  6. How many thefts each suspect has, with 0 for those with none.

casoabiertogame.com · SQL arcade and detective cases, free for the classroom

Want the answer key?

The worksheet answers and the solutions to all 28 cases aren't published, so students won't find them. Write to us from your institutional email and we'll send them, at no cost.

Request the answer key

The arcade, the lessons and the first two cases are free and need no account. For your group to have all 28 cases, the classroom license is free too: how to request it →