Re: Finding missing records
От
John D. Burger
Тема
Re: Finding missing records
Дата
Msg-id
76d00d2736badf0d1593d30d9666d7fb@mitre.org
Ответ на
Finding missing records (Stefano B.)
Список
Дерево обсуждения
Finding missing records "Stefano B." <stefano.bonnin@comai.to>
Re: Finding missing records Stephan Szabo <sszabo@megazone.bigpanda.com>
Re: Finding missing records "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: Finding missing records Pandurangan R S <pandurangan.r.s@gmail.com>
Re: Finding missing records "John D. Burger" <john@mitre.org>
Re: Finding missing records "John D. Burger" <john@mitre.org>
On Jan 27, 2006, at 08:59, Stefano B. wrote: > select f1,f2,f3,f4 from table1 where (f1,f2,f3,f4) NOT IN (select > f1,f2,f3,f4 from table2) > > but it seems not work (as I want). It returns me no records. If I use > the IN clause it returns me all 10000 table1 records. The standard way to do this is: select f1,f2,f3,f4 from table1 except select f1,f2,f3,f4 from table2; Note that IN and EXCEPT are essentially set operators - if you have duplicates in either table, you might not get what you expect. Your last comment above seems to indicate that this is indeed the case. If what you want is the =bag= difference of the two tables, you'll have to do something more complicated. Possible solutions might involve counting duplicates in both tables with a COUNT(*) and GROUP BY, and then joining on the four columns and subtracting the counts. - John D. Burger MITRE
В списке pgsql-general по дате отправления