Skip site navigation (1) Skip section navigation (2)

Re: compare 2 tables in sql

From: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: compare 2 tables in sql
Date: 2008-03-20 17:44:50
Message-ID: FE44E0D7EAD2ED4BB2165071DB8E328C0378F13E@egcrc-ex01.egcrc.org (view raw or flat)
Thread:
Lists: pgsql-sql
Hi Jonah,

Just a postscript.  It is important to check
both ways.  Because (sometimes) vice versa is
not necessarily true.  Case in point below:


blitzen=> select * from foo
blitzen-> except
blitzen->        select * from moo;
 alleleid | markerid | value | datecreated | datereplaced 
----------+----------+-------+-------------+--------------
(0 rows)

blitzen=> 
blitzen=> select * from moo
blitzen-> except
blitzen->        select * from foo;
  some_id | anothrid | value |       datecreated       |    datereplaced     
----------+----------+-------+-------------------------+---------------------
  2892473 |  2810329 | t     | 2008-03-12 14:37:18.165 | 3000-01-01 12:00:00
(1 row)


Regards,

Tena Sakai
tsakai(at)gallo(dot)ucsf(dot)edu


-----Original Message-----
From: Jonah H. Harris [mailto:jonah(dot)harris(at)gmail(dot)com]
Sent: Wed 3/19/2008 3:39 PM
To: Tena Sakai
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] compare 2 tables in sql
 
On Wed, Mar 19, 2008 at 1:56 PM, Tena Sakai <tsakai(at)gallo(dot)ucsf(dot)edu> wrote:
>  Is there a sql way to compare (in a diff/cmp sense)
>  2 tables?  For example,

SELECT * FROM foo
EXCEPT
SELECT * FROM moo;

-- 
Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
499 Thornall Street, 2nd Floor | jonah(dot)harris(at)enterprisedb(dot)com
Edison, NJ 08837 | http://www.enterprisedb.com/

In response to

Responses

pgsql-sql by date

Next:From: Jonah H. HarrisDate: 2008-03-20 19:21:32
Subject: Re: compare 2 tables in sql
Previous:From: Jan PetersDate: 2008-03-20 15:37:23
Subject: Re: Rollback locks table - why?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group