X-Original-To: pgsql-sql@postgresql.org Received: from utahisp.com (mail.cyber-wire.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id B3473476022 for ; Tue, 11 Mar 2003 16:24:44 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.14) id A3A1C3670288; Tue, 11 Mar 2003 14:22:41 -0700 Message-ID: <0b5901c2e814$9e19dc00$32021aac@chad> From: "Chad Thompson" To: "Terry Lee Tucker" , References: <3E6E2139.5060903@esc1.com> Subject: Re: Novice needs help Date: Tue, 11 Mar 2003 14:24:32 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Archive-Number: 200303/268 X-Sequence-Number: 12308 try something like... select c.* from cust c where not exists (select p.country from province p where p.country = c.country) This will give you a list of all the countries in cust that are not in province.. you can do the same with code. HTH Chad ----- Original Message ----- From: "Terry Lee Tucker" To: Sent: Tuesday, March 11, 2003 10:47 AM Subject: [SQL] Novice needs help > I have loaded over 29,000 customer records into a database. I'm trying > to apply a referential foreign key that validates the country code and > the province code in another table. It won't work because somewhere in > that 29,000 records there is a province code or country code that > doesn't match. Is there a way to use a select statement to find out > which customer records has the invalid data? Here is the partial table > layout: > > cust province > -------- ------- > country ===> country > province ===> code > > Thanks in advance... > > -- > Terry Lee Tucker > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >