Re: Finding missing records

From: Pandurangan R S <pandurangan(dot)r(dot)s(at)gmail(dot)com>
To: "Stefano B(dot)" <stefano(dot)bonnin(at)comai(dot)to>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding missing records
Date: 2006-01-27 14:03:59
Message-ID: 5e744e3d0601270603s6abbc665h180c15ba1fe4ed3e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

select f1,f2,f3,f4 from table1 EXCEPT ALL select f1,f2,f3,f4 from table2

http://www.postgresql.org/docs/8.1/static/sql-select.html

On 1/27/06, Stefano B. <stefano(dot)bonnin(at)comai(dot)to> wrote:
>
> Hi,
>
> I have two identical tables
>
> table1 (f1,f2,f3,f4 primary key (f1,f2,f3,f4))
>
> table2 (g1,g2,g3,g4 primary key (g1,g2,g3,g4))
>
> How can I find the difference between the two tables?
> table1 has 10000 records
> table2 has 9900 records (these records are in table1 as well)
>
> I'd like to find 100 missing records.
> I have try this query
>
> 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.
>
> Thanks in advance
> Stefano

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John D. Burger 2006-01-27 14:09:34 Re: Finding missing records
Previous Message A. Kretschmer 2006-01-27 14:03:42 Re: Finding missing records