Skip to content
IGCSE·Tuition
Computer Science · Lessons

Explain why a query returns no rows

An empty result is not an error message, so it can feel like the query has told you nothing.

On this page
  1. What are the usual causes?
  2. Worked example
  3. The mistake to watch for
  4. Check yourself
  5. Where this leads next

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:

  1. Conditions that cannot both be true. One field cannot equal two different values at once.
  2. A value outside the data. The tested value is not in the table, for example a price above the maximum.
  3. Spelling or type mismatch. "herbs" is not "Herb", and a number is not text.
  4. AND where OR was meant. AND demands every condition at once.
  5. A boundary problem. > excludes the value itself.

Worked example

Using the Plants table:

PlantIDNameTypePriceStockIndoor
P01FernFoliage12.508TRUE
P02CactusSucculent6.0025TRUE
P03RoseFlowering15.000FALSE
P04MintHerb4.5040FALSE
P05OrchidFlowering28.003TRUE
P06BasilHerb5.0012FALSE
P07AloeSucculent9.5015TRUE
P08HibiscusFlowering18.006FALSE
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.

Updated:

Your next step

If empty results leave you unsure whether the query or the data is at fault, a one-to-one teacher can show you a step-by-step check you can reuse on any question.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service