A query that returns an empty result is usually a wrong WHERE clause. But there is one class of empty result that confuses even experienced people, because every row it filters on looks correct: NOT IN with a NULL in the subquery. The failure Two tables. Customers, and the orders they placed: CREATE TABLE customers ( id int , name text ); CREATE TABLE orders ( customer_id int ); INSERT INTO customers VALUES ( 1 , 'Ada' ), ...