Practice Flashcards
Flip to reveal answersWhat does the ON condition in a JOIN do?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Joining two tables
Sign up free to track progress and get spaced-repetition review schedules.
Question
What does the ON condition in a JOIN do?
Answer
It names the two columns that must match — almost always a foreign key and the primary key it points at. Without it, every row of one table pairs with every row of the other.
Question
In what order are SQL clauses applied?
Answer
FROM and JOIN decide which rows exist, WHERE filters them, GROUP BY collapses them, HAVING filters the groups, SELECT picks the columns, and ORDER BY sorts. SELECT is written first but applied near the end.
Question
What is the difference between WHERE and HAVING?
Answer
WHERE filters individual rows before grouping. HAVING filters groups after grouping, and is the only place a condition on a count or total can go, because that value does not exist until GROUP BY has run.
Question
How does LIKE with the % wildcard work?
Answer
% stands for any run of characters. 'Sm%' matches anything starting Sm, '%son' anything ending son, and '%ann%' anything containing ann.
Question
When is DISTINCT needed in a joined query?
Answer
When the join can legitimately produce the same row more than once — a student belonging to two clubs would otherwise appear twice in a list of names.
Read the notes
Full study notes for Joining two tables
Topic 3.3 hub
Database programming
More from Topic 3.3
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free