This module is about storing data in a table and asking questions of it. You will name the parts of a table, choose a key that identifies each record, write a SELECT query with a condition, combine conditions correctly, and explain why a query returns nothing.
Check the current Cambridge Computer Science 0478 syllabus for the exact query features in your exam year. Our Computer Science learning guide shows where this module sits among the others.
What should you already know?
You need to read a table of rows and columns and to compare values with =, < and >. Basic Boolean ideas help too: AND needs both conditions true, OR needs at least one. Boolean and number-representation lab lets you try those on small examples.
An orienting example
A fictional plant shop stores its stock in a table called Plants. All the lessons in this module reuse it.
| PlantID | Name | Type | Price | Stock | Indoor |
|---|---|---|---|---|---|
| P01 | Fern | Foliage | 12.50 | 8 | TRUE |
| P02 | Cactus | Succulent | 6.00 | 25 | TRUE |
| P03 | Rose | Flowering | 15.00 | 0 | FALSE |
| P04 | Mint | Herb | 4.50 | 40 | FALSE |
| P05 | Orchid | Flowering | 28.00 | 3 | TRUE |
| P06 | Basil | Herb | 5.00 | 12 | FALSE |
| P07 | Aloe | Succulent | 9.50 | 15 | TRUE |
| P08 | Hibiscus | Flowering | 18.00 | 6 | FALSE |
Question: which flowering plants are in stock?
SELECT Name
FROM Plants
WHERE Type = "Flowering" AND Stock > 0
Check each record.
Rose is flowering but Stock is 0, so it fails. Orchid (3) and Hibiscus (6) pass both conditions. The result is two rows: Orchid and Hibiscus.
In what order should you study the lessons?
- Distinguish field, record and table: every later lesson uses these words, so fix them first.
- Choose a suitable key: a key explains why each record can be found exactly once.
- Write a simple SELECT filter: the core skill, one condition at a time.
- Combine conditions with the correct Boolean grouping: AND, OR and brackets change which rows survive.
- Explain why a query returns no rows: reasoning that checks a query against the data.
Then test yourself with the original practice set. The read-only SQL practice lab runs safe SELECT queries on a fictional database.
Which traps catch most students?
- Writing a text value without quotation marks, or using the wrong spelling of a field name.
- Mixing up the columns you display (SELECT) with the columns you test (WHERE).
- Forgetting that AND is stricter than OR, so adding AND can only remove rows.
- Reading
>as “at least”:Price > 28excludes a plant priced exactly 28.00.
How should you use the practice set?
Cover the answer, write the query or result yourself, then check row by row against the table. Log each wrong answer with its cause in the mistake log so the same slip does not return. For tuition built around this topic, see our online one-to-one Computer Science tuition.