Re: [GENERAL] Incorrect results with NOT IN

2008-08-17 Thread Nick
Wow, very good to know. That was driving me crazy. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Incorrect results with NOT IN

2008-08-14 Thread Pavel Stehule
2008/8/15 Nick <[EMAIL PROTECTED]>: > 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

[GENERAL] Incorrect results with NOT IN

2008-08-14 Thread Nick
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 (