← IGCSE Computer Science Paper 2

Common mistakes in SQL scripts

A mistake in an SQL script, such as text without quotes, > instead of >=, AND instead of OR, clauses in the wrong order, a missing table after FROM or a missing semicolon.

Understanding Common mistakes in SQL scripts in IGCSE Computer Science Paper 2

What it does: The >= operator includes the boundary value 100, while > would miss students with exactly 100 points. A record only needs to meet one of the two conditions, so OR is correct. AND would return no rows. Text values must be inside quotes. Without quotes, SQL treats Red as a field name and the query fails. A student has only one year level, so AND returns no records. OR is needed when either condition can be true. The order is SELECT, FROM, WHERE, ORDER BY. WHERE must come before ORDER BY. Use > when the boundary value must be excluded. Use >= when it must be included. Check the wording of the requirement carefully.

Common mistakes: The table name is missing after FROM. SQL needs to know which table to read, so it should be FROM students. Text values in a WHERE condition must be inside quotes. It should be WHERE category = 'Tech'.

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 539–551) and word search (Modules 539–580).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which query correctly finds students in house Red?
SELECT * FROM students WHERE house = Red;SELECT * FROM students WHERE house = 'Red';
Matches
SELECT firstName, points WHERE points > 50;
↓
The table name is missing: FROM and the table name (students) must follow the field list.
Applying
Meanings
Term
SQL error
Meaning
A mistake in an SQL script, such as text without quotes, > instead of >=, AND instead of OR, clauses in the wrong order, a missing table after FROM or a missing semicolon.
Practice
SELECT firstName, house, points
Testing
Gaps
FROM
Check Answer
Spots
1SELECT firstName, house
2FROM

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

The 'Cosmic Dragon' badge — Orbit Master, 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 correctly finds students in house Red?
A. SELECT * FROM students WHERE house = 'Red'; ✓
B. SELECT * FROM students WHERE house = Red;
Text values must be inside quotes. Without quotes, SQL treats Red as a field name and the query fails.
2. A student wants all products that cost 10 or more. Which condition is correct?
A. WHERE price > 10
B. WHERE price >= 10 ✓
> leaves out products costing exactly 10. Use >= to include the boundary value.
3. A query must find students in year 7 OR year 8. Which WHERE clause is correct?
A. WHERE yearLevel = 7 OR yearLevel = 8 ✓
B. WHERE yearLevel = 7 AND yearLevel = 8
A student has only one year level, so AND returns no records. OR is needed when either condition can be true.
4. Which query has its clauses in the correct order?
A. SELECT * FROM students WHERE points > 100 ORDER BY lastName; ✓
B. SELECT * FROM students ORDER BY lastName WHERE points > 100;
The order is SELECT, FROM, WHERE, ORDER BY. WHERE must come before ORDER BY.
5. Which query names the table correctly?
A. SELECT firstName FROM;
B. SELECT firstName FROM students; ✓
FROM must be followed by the table name, so SQL knows where to find the data.

Match the Pairs

SELECT * FROM students WHERE house = Red; → Error: the text value Red has no quotes, so SQL treats it as a field name. It should be 'Red'.
SELECT * FROM students ORDER BY points WHERE yearLevel = 7; → Error: the clauses are in the wrong order. WHERE must come before ORDER BY.
To find students with 100 points or more, use >= because > would leave out students on exactly 100. → SELECT firstName FROM students WHERE points >= 100;
To find students in year 7 or year 8, use OR because no student can be in both years at once. → SELECT * FROM students WHERE yearLevel = 7 OR yearLevel = 8;
SELECT firstName, points WHERE points > 50; → The table name is missing: FROM and the table name (students) must follow the field list.
SELECT * FROM products WHERE category = 'Tech' AND category = 'Sport'; → AND is used when OR is needed: a product cannot be in two categories at once, so no records match.

Key Term

SQL error
A mistake in an SQL script, such as text without quotes, > instead of >=, AND instead of OR, clauses in the wrong order, a missing table after FROM or a missing semicolon.

Fill in the Blanks

1. SELECT firstName FROM students WHERE points > 100;
Hint: Type the table name that must come after FROM, so the query knows where the data is.
2. -- Students with 100 points or more SELECT firstName FROM students WHERE points >= 100;
Hint: Type the comparison operator that also includes the boundary value itself.
3. -- Products in either category SELECT name FROM products WHERE category = 'Tech' OR category = 'Sport';
Hint: Type the logical operator needed when a record can match either condition, since no row has two categories.
4. SELECT firstName FROM students WHERE house = 'Red' ORDER BY points DESC;
Hint: Type the clause that sorts the results; it must come after WHERE.
5. SELECT name FROM products WHERE category = 'Tech' ORDER BY price;
Hint: Type the clause keyword that filters records; it must come before ORDER BY, not after it.

Spot the Error

Question 1
A SELECT firstName, house
B FROM
C WHERE house = 'Red';
Line B — The table name is missing after FROM. SQL needs to know which table to read, so it should be FROM students.
Question 2
A SELECT name FROM products
B WHERE category = Tech
C ORDER BY price;
Line B — Text values in a WHERE condition must be inside quotes. It should be WHERE category = 'Tech'.
Question 3
A SELECT firstName
B FROM students
C WHERE house = 'Red'
D AND house = 'Blue';
Line D — A student is in only one house, so AND would return no rows. To get students from either house, use OR.
Question 4
A -- Points of 100 or more
B SELECT firstName FROM students
C WHERE points > 100
D ORDER BY points;
Line C — The task needs 100 points or more, so 100 must be included. > leaves out students with exactly 100, so use >=.
Question 5
A SELECT COUNT(*) FROM students
B SELECT SUM(points)
C FROM students;
Line A — The first statement is missing its semicolon, so it runs into the next statement. It should end with ;.

Student with a class code? Join your class →