Success. No rows returned: what it means and how to find the missing rows
"Success. No rows returned" means your query ran without an error and gave back an empty result. After CREATE, INSERT, UPDATE or DELETE that's normal: those statements change things, they don't return rows. After a SELECT, it means no row passed your filter, usually because the data isn't written the way the filter expects.
How it usually happens
You write a SELECT you're sure about, run it, and get a green "Success" with nothing under it. No error to search for, nothing to fix, and you know the rows are in the table. The query did exactly what you wrote. The gap is between what you wrote and what's in the data.
First, check what kind of statement it was
If it was a CREATE TABLE, an INSERT, an UPDATE or a DELETE, you're done: it worked. To see what changed, run a SELECT on the table afterwards. Everything below is about a SELECT that should have found something.
The table
| id | name | city | |
|---|---|---|---|
| 1 | Ana | Lima | ana@mail.com |
| 2 | Ben | Lima | ben@mail.com |
| 3 | Chloe | Cusco | NULL |
| 4 | Dev | Arequipa | dev@mail.com |
Look closely at Ben's city: there's a space after "Lima". Chloe has no email.
1. The text doesn't match exactly
SELECT name
FROM customers
WHERE city = 'lima';
No rows. Text comparison in PostgreSQL is exact: "lima" isn't "Lima", and "Lima" isn't "Lima " with a space. Clean both sides before comparing:
SELECT name
FROM customers
WHERE LOWER(TRIM(city)) = 'lima';
| name |
|---|
| Ana |
| Ben |
2. You compared with NULL using =
SELECT name
FROM customers
WHERE email = NULL;
No rows, even though Chloe has no email. NULL means "unknown", and nothing is ever equal to unknown, not even another NULL. Use IS NULL:
SELECT name
FROM customers
WHERE email IS NULL;
| name |
|---|
| Chloe |
3. AND where you meant OR
SELECT name
FROM customers
WHERE city = 'Cusco' AND city = 'Arequipa';
No rows. In English you'd say "customers in Cusco and Arequipa", but one row can't have two cities at once. You want either one:
SELECT name
FROM customers
WHERE city IN ('Cusco', 'Arequipa');
| name |
|---|
| Chloe |
| Dev |
4. A join or NOT IN removed everything
If the query has a JOIN, an inner join drops every row without a match, and a WHERE on the right-hand table can do the same to a LEFT JOIN. If it has NOT IN with a subquery, one NULL in the list empties the whole result. Both have their own guides, linked at the bottom.
How to find the cause fast: remove the WHERE and run the query again. Then add the conditions back one at a time. The one that empties the result is the one to look at.
Try it yourself
A tea shop wants the teas it still sells. The category was typed by hand, and a product that's no longer sold has a date in discontinued_on.
| id | name | category | discontinued_on |
|---|---|---|---|
| 1 | Green tea | Tea | NULL |
| 2 | Chai | tea | NULL |
| 3 | Earl Grey | Tea | 2026-03-01 |
| 4 | Espresso | Coffee | NULL |
The query below is meant to list the teas still on sale, as name, sorted by name. It returns no rows. Fix it so it finds the two.
Hint
Two things stop every row: how the category is written, and how the query checks for an empty date.
Show solution
SELECT name
FROM products
WHERE LOWER(TRIM(category)) = 'tea'
AND discontinued_on IS NULL
ORDER BY name;| name |
|---|
| Chai |
| Green tea |
MintQuery has 500+ exercises like this one, in lessons of a few minutes.
Start freeGet the appStart in your browser, no account needed.