← VCE Spreadsheets, SQL & Visualisation

SQL WHERE conditions

An SQL clause that keeps only the rows meeting a condition, such as WHERE age >= 15 or WHERE town = 'Perth'. Text goes in quotes, and AND or OR can combine conditions.

Understanding SQL WHERE conditions in VCE Spreadsheets, SQL & Visualisation

What it does: Text such as Maths goes inside single quotes so SQL treats it as a value, not a column name. With AND, a student must be at least 15 and in Year 10 to be included in the results. The 'greater than or equal to' operator is written >= in SQL. => is not a valid comparison operator. WHERE filters the rows. Only records where the condition is true are included in the results. AND means both conditions must be true. OR would also include Year 9 students who are 16 or over, or Year 10 students who are younger than 16.

Common mistakes: WHILE is not an SQL clause. The keyword that filters rows by a condition is WHERE, so the line should be SELECT name FROM pets WHERE. => is not a valid comparison operator. 'Greater than or equal to' is written >=, so the line should be AND age >= 15;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 45–54) and word search (Modules 35–54).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which query keeps only students who are 15 or older?
SELECT * FROM students WHERE age => 15;SELECT * FROM students WHERE age >= 15;
Matches
SELECT * FROM students WHERE town = Perth;
↓
The text value Perth is missing quotes. It should be 'Perth'.
Applying
Meanings
Term
WHERE
Meaning
An SQL clause that keeps only the rows meeting a condition, such as WHERE age >= 15 or WHERE town = 'Perth'. Text goes in quotes, and AND or OR can combine conditions.
Practice
SELECT name, age
Testing
Gaps
SELECT * FROM students age >= 15;
Check Answer
Spots
1SELECT name FROM pets WHILE
2age > 3 AND type = 'dog'

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Camel' badge — Endurance Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which query keeps only students who are 15 or older?
A. SELECT * FROM students WHERE age >= 15; ✓
B. SELECT * FROM students WHERE age => 15;
The 'greater than or equal to' operator is written >= in SQL. => is not a valid comparison operator.
2. Which WHERE condition correctly matches students who live in Perth?
A. WHERE town = Perth
B. WHERE town = 'Perth' ✓
Text values must be placed in quotes. Without quotes, SQL thinks Perth is a column name and gives an error.
3. True or false: WHERE keeps only the rows that meet the condition.
A. False
B. True ✓
WHERE filters the rows. Only records where the condition is true are included in the results.
4. Which query finds students in Year 10 AND aged 16 or over?
A. WHERE year = 10 AND age >= 16 ✓
B. WHERE year = 10 OR age >= 16
AND means both conditions must be true. OR would also include Year 9 students who are 16 or over, or Year 10 students who are younger than 16.
5. Which query finds students who play either 'Netball' or 'Soccer'?
A. WHERE sport = 'Netball' OR sport = 'Soccer' ✓
B. WHERE sport = 'Netball' AND sport = 'Soccer'
One row can't have two different values in the same field, so AND would return nothing. OR keeps rows that match either condition.

Match the Pairs

SELECT * FROM students WHERE age >= 15; → Shows only the students who are 15 or older
WHERE town = 'Perth' OR town = 'Darwin' → Keeps rows where the town is either Perth or Darwin
Text values in a WHERE condition must be wrapped in quotes → WHERE subject = 'Maths'
AND keeps a row only when both conditions are true → WHERE age >= 15 AND year = 10
SELECT * FROM students WHERE town = Perth; → The text value Perth is missing quotes. It should be 'Perth'.
SELECT * FROM students WHERE age => 15; → The comparison operator is written backwards. It should be >= not =>.

Key Term

WHERE
An SQL clause that keeps only the rows meeting a condition, such as WHERE age >= 15 or WHERE town = 'Perth'. Text goes in quotes, and AND or OR can combine conditions.

Fill in the Blanks

1. SELECT * FROM students WHERE age >= 15;
Hint: Type the clause keyword that keeps only the rows meeting a condition.
2. SELECT name FROM students WHERE age >= 15;
Hint: Type the comparison operator meaning greater than or equal to.
3. SELECT * FROM students WHERE town = 'Perth' AND age >= 15;
Hint: Type the keyword that requires both conditions to be true.
4. SELECT name FROM students WHERE town = 'Perth' OR town = 'Hobart';
Hint: Type the keyword that keeps a row if either condition is true.
5. SELECT title FROM books WHERE price < 20;
Hint: Type the comparison operator meaning less than.

Spot the Error

Question 1
A SELECT name FROM pets WHILE
B age > 3 AND type = 'dog'
C ORDER BY name;
Line A — WHILE is not an SQL clause. The keyword that filters rows by a condition is WHERE, so the line should be SELECT name FROM pets WHERE.
Question 2
A SELECT name, town
B FROM students
C WHERE town = 'Perth'
D AND age => 15;
Line D — => is not a valid comparison operator. 'Greater than or equal to' is written >=, so the line should be AND age >= 15;
Question 3
A SELECT name
B FROM players
C WHERE score > 50
D AND team = Reds;
Line D — Text values must be in quotes. Without them SQL treats Reds as a column name. It should be AND team = 'Reds';
Question 4
A SELECT * movies
B WHERE year >= 2010
C AND genre = 'comedy';
Line A — The FROM keyword is missing, so SQL does not know which table to read. It should be SELECT * FROM movies.
Question 5
A SELECT name FROM staff
B WHERE role == 'Tutor'
C OR role = 'Coach';
Line B — SQL tests equality with a single = sign, not ==. The line should be WHERE role = 'Tutor'.

Student with a class code? Join your class →