Boolean operators AND, OR and NOT in a WHERE clause
Combine WHERE conditions: AND needs both true, OR needs at least one true, NOT reverses a condition. Brackets set the order and decide which rows are returned.
Understanding Boolean operators AND, OR and NOT in a WHERE clause in VCE Data Analytics U3O1
What it does: NOT flips the result of house = 'Blue', so only rows from other houses are returned. The brackets make the house OR test happen first, then points > 90 must also be true for every row returned. OR needs at least one condition to be true. A product has only one category, so it can never be both Tech and Sport, and AND would return no rows. NOT goes in front of the condition it reverses. Placing NOT after the = sign is a syntax error. The Calculator passes both tests. The Water Bottle fails both, since its price is under 10 and its stock is 0, so AND rejects it.
Common mistakes: The comment says items must be cheap AND in stock. OR returns a row if only one condition is true, so it would include out-of-stock items. It should be WHERE price < 30 AND stock > 0. SQL conditions must follow the keyword WHERE, not WHEN. The AND on the later line only works once WHERE has started the condition. It should be SELECT * FROM students WHERE.
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 17–49) and word search (Modules 17–91).
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
AND, OR, NOTFill in the Blanks
Spot the Error
Student with a class code? Join your class →