pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How do you compare contents of two tables using 2 pk
2+ messages / 2 participants
[nested] [flat]

* How do you compare contents of two tables using 2 pk
@ 2005-02-24 17:17  Kent Anderson <kenta@ezyield.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Kent Anderson @ 2005-02-24 17:17 UTC (permalink / raw)
  To: pgsql-sql

I have two tables that should contain the same number or records. Both
tables use the same 2 foreign keys as their primary keys.

I did a count on the number of records in both and found one table has 500
records less than the first table so I need to know which records are not in
the second table.

table 1
t1_fk_wm (FK)
t1_fk_hm (FK)
...
...
...

table 2
t2_fk_wm  (FK)
t2_fk_hm  (FK)
....

Table 2 doesn't have the same number of records as the first table however
it should.

Any suggestions would be appreciated as I am still very much a beginner at
SQL.

Kent Anderson

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How do you compare contents of two tables using 2 pk
@ 2005-02-24 17:36  Joel Fradkin <jfradkin@wazagua.com>
  parent: Kent Anderson <kenta@ezyield.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Joel Fradkin @ 2005-02-24 17:36 UTC (permalink / raw)
  To: 'Kent Anderson' <kenta@ezyield.com>; pgsql-sql

Couldn’t you do a select * from t1 where not in uniquevar (select uniquevar
from t2)?
Or do a join and select on a value in t2 being null.

Joel Fradkin
 





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-02-24 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 17:17 How do you compare contents of two tables using 2 pk Kent Anderson <kenta@ezyield.com>
2005-02-24 17:36 ` Joel Fradkin <jfradkin@wazagua.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox