← IGCSE Computer Science Paper 2

WHERE on text, Boolean, character and date fields

The value in a WHERE condition must match the field's data type: text and characters go in quotes, numbers do not, and Boolean fields use TRUE or FALSE, e.g. Member = TRUE.

Understanding WHERE on text, Boolean, character and date fields in IGCSE Computer Science Paper 2

What it does: Character values like A are still text, so they need quotes in the condition. A date value is written in quotes, and operators such as > compare dates in order. A Boolean field is compared with TRUE or FALSE, not with words in quotes like 'No'.

Common mistakes: Grade is a character field, so the value must be in quotes. Without them, A looks like a field name. It should be WHERE Grade = 'A'. Town is a text field, so Leeds needs quotes. Without them SQL treats Leeds as a field name. It should be AND Town = 'Leeds';.

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 525–538) and word search (Modules 500–538).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which WHERE clause correctly finds students who live in Leeds?
WHERE Town = 'Leeds'WHERE Town = Leeds
Matches
WHERE Town = Leeds
↓
The text value Leeds has no quotes, so it is read as a field name instead of text. It should be 'Leeds'.
Applying
Meanings
Term
WHERE Town = 'Leeds'
Meaning
The value in a WHERE condition must match the field's data type: text and characters go in quotes, numbers do not, and Boolean fields use TRUE or FALSE, e.g. Member = TRUE.
Practice
SELECT firstName, lastName, house
Testing
Gaps
WHERE Member = ;
Check Answer
Spots
1SELECT Name FROM Student
2WHERE Grade = A

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

The 'Firefly' badge — Night Coder, 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 WHERE clause correctly finds students who live in Leeds?
A. WHERE Town = 'Leeds' ✓
B. WHERE Town = Leeds
Text values must be inside quotes. Without quotes, Leeds looks like a field name.
2. Which WHERE clause correctly finds records where Grade is the character A?
A. WHERE Grade = 'A' ✓
B. WHERE Grade = A
A single character value is a text value, so it goes in quotes: 'A'.
3. Which WHERE clause correctly finds members when Member is a Boolean field?
A. WHERE Member = 'TRUE'
B. WHERE Member = TRUE ✓
Boolean values are written as TRUE or FALSE with no quotes. Quotes would turn it into text.
4. Which is the correct way to find records where Member is FALSE?
A. WHERE Member = FALSE ✓
B. WHERE Member = 'No'
A Boolean field is compared with TRUE or FALSE, not with words in quotes like 'No'.
5. Which WHERE clause correctly matches a Year field that is an integer, with the value 11?
A. WHERE Year = '11'
B. WHERE Year = 11 ✓
Numbers are not put in quotes. Quotes are for text and character values.

Match the Pairs

WHERE Town = 'Leeds' → Selects only records where the text field Town holds Leeds, so the text value is written in quotes
WHERE Member = TRUE → Selects only records where the Boolean field Member is true, with TRUE written without quotes
A single character field such as a grade is compared using the character in quotes → WHERE Grade = 'A'
A date field is compared with a date value written in quotes, using a comparison operator → WHERE JoinDate > '2024-01-01'
WHERE Town = Leeds → The text value Leeds has no quotes, so it is read as a field name instead of text. It should be 'Leeds'.
WHERE Member = 'TRUE' → TRUE is a Boolean value and must not be in quotes, which turn it into text. It should be Member = TRUE.

Key Term

WHERE Town = 'Leeds'
The value in a WHERE condition must match the field's data type: text and characters go in quotes, numbers do not, and Boolean fields use TRUE or FALSE, e.g. Member = TRUE.

Fill in the Blanks

1. -- current members only SELECT Name FROM Club WHERE Member = TRUE;
Hint: Type the Boolean value that selects the records where the field is switched on. Boolean values are not put in quotes.
2. -- students who got grade A SELECT Name FROM Student WHERE Grade = 'A';
Hint: Type the name of the field that holds the single character being compared. The comment tells you which field it is.
3. SELECT * FROM Customer WHERE Town = 'Leeds';
Hint: Type the SQL keyword that introduces the condition used to filter records.
4. SELECT * FROM Orders WHERE OrderDate > #01/01/2024#;
Hint: Type the comparison operator that finds dates later than the given date.
5. -- members who have not renewed SELECT Name FROM Club WHERE Renewed = FALSE;
Hint: Type the Boolean value for the records where the field is switched off. It is not written in quotes.

Spot the Error

Question 1
A SELECT Name FROM Student
B WHERE Grade = A
C ORDER BY Name;
Line B — Grade is a character field, so the value must be in quotes. Without them, A looks like a field name. It should be WHERE Grade = 'A'.
Question 2
A SELECT Name, Town
B FROM Customer
C WHERE Member = TRUE
D AND Town = Leeds;
Line D — Town is a text field, so Leeds needs quotes. Without them SQL treats Leeds as a field name. It should be AND Town = 'Leeds';
Question 3
A SELECT Name, Member
B FROM Club
C WHERE Member = 'TRUE';
Line C — Member is a Boolean field, so TRUE is written without quotes. Quotes would turn it into a text string. It should be WHERE Member = TRUE;
Question 4
A SELECT Name, Fee
B FROM Club
C WHERE Member = TRUE
D AND Fee > '20';
Line D — Fee is a number field, so the value 20 must not be in quotes. Quotes make it text. It should be AND Fee > 20;
Question 5
A SELECT Name, Gender
B FROM Pupil
C WHERE Gender = F;
Line C — Gender holds a single character, and character values need quotes just like text. It should be WHERE Gender = 'F';

Student with a class code? Join your class →