A query returns no rows when no record passes every condition. The query still ran correctly: the database simply found nothing that matched.
Exam questions ask you to explain this in words, so you need to point to the exact reason. This lesson finishes databases and query reasoning.
What are the usual causes?
Check these in order:
- Conditions that cannot both be true. One field cannot equal two different values at once.
- A value outside the data. The tested value is not in the table, for example a price above the maximum.
- Spelling or type mismatch.
"herbs"is not"Herb", and a number is not text. - AND where OR was meant. AND demands every condition at once.
- A boundary problem.
>excludes the value itself.
Worked example
Using the Plants table:
| 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 |
SELECT Name FROM Plants
WHERE Type = "Flowering" AND Indoor = TRUE AND Stock > 5
The query returns no rows. Why?
Step 1, list the records that pass the first condition. Type = “Flowering”: Rose, Orchid, Hibiscus.
Step 2, apply the second condition. Indoor = TRUE: Rose is FALSE, Orchid is TRUE, Hibiscus is FALSE. Only Orchid is left.
Step 3, apply the third condition. Stock > 5: Orchid has 3, which is not greater than 5. Orchid fails.
Step 4, state the reason. The only flowering indoor plant is Orchid, and its stock is 3, so no record meets all three conditions.
Final answer: no rows, because the single record that passes the first two tests fails the Stock test. Filtering one condition at a time shows exactly where the last record drops out.
The mistake to watch for
A common slip is to answer “the table is empty” or “the query has an error”.
Mistaken answer: “The Plants table has no flowering plants.”
That is false: Rose, Orchid and Hibiscus are flowering.
The correction: name the surviving record after each condition and say which test removes it. Explaining a no-row result without naming a condition earns no credit.
Check yourself
1. Why does WHERE Type = "Herb" AND Type = "Succulent" return nothing?
Show answer
One record has only one value in Type, so it cannot be both Herb and Succulent. The conditions cannot both be true. OR would return Mint, Basil, Cactus and Aloe.
2. Why does WHERE Price > 28 return nothing, and what change returns a row?
Show answer
The highest price is 28.00 (Orchid), and > excludes it. Changing to >= 28 returns Orchid.
3. A student writes WHERE Type = "herb". Which row count would they expect, and what might they get?
Show answer
They expect 2 rows (Mint, Basil). Whether the lowercase spelling matches depends on whether the database ignores capitals, so match the stored spelling "Herb" exactly to be safe.
Where this leads next
Finish the module with the original practice set. Try empty-result cases in the read-only SQL practice lab to see them in action.
If you want help turning explanations like these into clear exam answers, see our online one-to-one Computer Science tuition.