Incorrect results with NOT IN - Mailing list pgsql-general

From Nick
Subject Incorrect results with NOT IN
Date
Msg-id 45648a47-38d3-4bad-8471-4b6c264bc78e@z6g2000pre.googlegroups.com
Whole thread Raw
Responses Re: Incorrect results with NOT IN
List pgsql-general
I have a weird scenario on a table when I run this query...

table1 has 1500 rows
table2 has 1200 rows
table2.id is a foreign key of table1.id

SELECT COUNT(*) FROM table1
WHERE id NOT IN (
  SELECT id FROM table2
);

however, using NOT EXISTS works

SELECT COUNT(*) FROM table1
WHERE NOT EXISTS (
  SELECT id FROM table2 WHERE table1.id = table2.id
);

Can you not use NOT IN over a specific number of values??

pgsql-general by date:

Previous
From: "Brent Wood"
Date:
Subject: Re: Query help
Next
From: Dale
Date:
Subject: syntax error at or near "PERFORM"