A join that forgets the ON condition
A join with no ON condition pairs every row of one table with every row of the other, so 3 customers and 4 orders give 12 rows, most of them wrong.
Understanding A join that forgets the ON condition in ACARA Digital Technologies Years 9–10
What it does: Without ON, the row count is rows x rows. Counting the rows of the unconditioned join shows the multiplication, e.g. 10 students x 10 orders = 100. The ON condition links the foreign key orders.productId to the primary key products.productId, so only matching rows are paired. The first query has no ON condition, so each student row is paired with every results row. A sudden jump in row count is the warning sign of a join with no ON condition. The database does not invent data. Join on the foreign key and the primary key it points to. Quantity and points are unrelated fields, so matches would be meaningless.
Common mistakes: The ON condition compares the customer's id with the order's own id, not the customer it belongs to. The rows are paired on the wrong fields. It should be ON c.id = o.customerId; (primary key = foreign key). This compares the students table with itself, so it is true for every row. Every student is still paired with every order. It should be ON s.studentId = o.studentId; to link students to orders.
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) and definitions worksheet (Modules 459–475) and word scramble (Modules 459–475).
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
▶ Run these on the board — two answers, the class points left or right, you reveal why. No devices.
Match the Pairs
Key Term
Cartesian productFill in the Blanks
Spot the Error
Student with a class code? Join your class →
Classroom tools: Hangman · Bingo · Heads or Tails · Higher or Lower · Name Picker · Team Generator · Seating Plan