From kenta@ezyield.com Thu Feb 24 17:18:35 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5129D556EA for ; Thu, 24 Feb 2005 17:18:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19418-05 for ; Thu, 24 Feb 2005 17:18:31 +0000 (GMT) Received: from mail.ezyield.com (unknown [64.40.98.102]) by svr1.postgresql.org (Postfix) with ESMTP id D90EF5567D for ; Thu, 24 Feb 2005 17:18:29 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.ezyield.com (8.12.11/8.12.11) with ESMTP id j1OHKUdF001157 for ; Thu, 24 Feb 2005 12:20:30 -0500 Received: from mail.ezyield.com ([127.0.0.1]) by localhost (mail.ezyield.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 32415-02 for ; Thu, 24 Feb 2005 12:20:28 -0500 (EST) Received: from KENTA (gateway [67.108.170.254]) by mail.ezyield.com (8.12.11/8.12.11) with SMTP id j1OHJVAv000560 for ; Thu, 24 Feb 2005 12:19:35 -0500 From: "Kent Anderson" To: "Pgsql-Sql@Postgresql. Org" Subject: How do you compare contents of two tables using 2 pk Date: Thu, 24 Feb 2005 12:17:48 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_005F_01C51A6A.DAA020F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: amavisd-new 2.2.0 at ezyield.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.332 tagged_above=0 required=5 tests=FORGED_MUA_OIMO, HTML_MESSAGE X-Spam-Level: * X-Archive-Number: 200502/315 X-Sequence-Number: 20425 This is a multi-part message in MIME format. ------=_NextPart_000_005F_01C51A6A.DAA020F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_005F_01C51A6A.DAA020F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have = two tables=20 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=20 number of records in both and found one table has 500 records less than = the=20 first table so I need to know which records are not in the second=20 table.
 
table=20 1
t1_fk_wm (FK)
t1_fk_hm (FK)
...
...
...
 
table=20 2
t2_fk_wm  = (FK)
t2_fk_hm  = (FK)
....
 
Table = 2 doesn't have=20 the same number of records as the first table however it=20 should.
 
Any = suggestions=20 would be appreciated as I am still very much a beginner = at SQL. =20
 
Kent = Anderson
------=_NextPart_000_005F_01C51A6A.DAA020F0-- From jfradkin@wazagua.com Thu Feb 24 17:32:15 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 03A64550E7 for ; Thu, 24 Feb 2005 17:32:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25006-02 for ; Thu, 24 Feb 2005 17:32:13 +0000 (GMT) Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) by svr1.postgresql.org (Postfix) with ESMTP id 233DB563B7 for ; Thu, 24 Feb 2005 17:32:08 +0000 (GMT) Received: from jfradkin ([66.15.127.235]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0ICF00G1MFDUZ030@vms048.mailsrvcs.net> for pgsql-sql@postgresql.org; Thu, 24 Feb 2005 11:32:19 -0600 (CST) Date: Thu, 24 Feb 2005 12:36:16 -0500 From: "Joel Fradkin" Subject: Re: How do you compare contents of two tables using 2 pk In-reply-to: To: "'Kent Anderson'" , "'Pgsql-Sql@Postgresql. Org'" Message-id: <005601c51a97$58bf67d0$797ba8c0@jfradkin> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=3.152 tagged_above=0 required=5 tests=AWL, MSGID_DOLLARS X-Spam-Level: *** X-Archive-Number: 200502/317 X-Sequence-Number: 20427 Couldn=92t 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 =A0