A join with WHERE and ORDER BY
After JOIN ... ON links two tables, WHERE filters the joined rows and ORDER BY sorts them. Clause order: SELECT, FROM, JOIN ON, WHERE, ORDER BY.
Understanding A join with WHERE and ORDER BY in ACARA Digital Technologies Years 9–10
What it does: This query puts the clauses in the right order: JOIN ... ON is before WHERE, and ORDER BY is at the very end. The WHERE clause uses products.category, a field from the second table, to keep only Stationery rows after the join. DESC sorts from largest to smallest. HIGHEST is not an SQL keyword.
Common mistakes: The ON condition must match the foreign key to the primary key it refers to. results.studentId links to students.studentId, so it should be ON s.studentId = r.studentId. A JOIN must be followed by ON, not WHERE. WHERE is saved for filtering the joined rows. The line should be ON p.productId = o.productId.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 459–475) and word search (Modules 459–534).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
JOIN ... ON ... WHERE ... ORDER BYFill in the Blanks
Spot the Error
Student with a class code? Join your class →