Consider this snippet of SQL:
CREATE TABLE product
(
id integer,
stock_quantity integer
);
INSERT INTO product (id, stock_quantity) VALUES (1, NULL);
INSERT INTO product (id, stock_quantity) VALUES (2, NULL);
SELECT *
FROM product
WHERE (id, stock_quantity) NOT IN ((1, 2), (2, 9));
I can't understand why it doesn't select anything. I'm using Postgres.
I would expect both rows to be returned, because I'd expect (1, NULL) and (2, NULL) to not be in ((1,2), (2, 9)).
If I replace NULL with 0, for example, it does return the two results.
Why was it designed to be this way? What am I missing?
Thanks!