Tech
The NOT IN trap: why your SQL query returns zero rows
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' ), ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to