pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chad Thompson <chad@weblinkservices.com>
To: Terry Lee Tucker <terry@esc1.com>
To: pgsql-sql@postgresql.org
Subject: Re: Novice needs help
Date: Tue, 11 Mar 2003 14:24:32 -0700
Message-ID: <0b5901c2e814$9e19dc00$32021aac@chad> (raw)
References: <3E6E2139.5060903@esc1.com>

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" <terry@esc1.com>
To: <pgsql-sql@postgresql.org>
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)
>




view thread (6+ messages)  latest in thread

Message-ID: <0b5901c2e814$9e19dc00$32021aac@chad>
Permalink:  ../0b5901c2e814$9e19dc00$32021aac@chad/
Also on:    postgresql.org/message-id/0b5901c2e814$9e19dc00$32021aac@chad

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chad@weblinkservices.com, terry@esc1.com
  Subject: Re: Novice needs help
  In-Reply-To: <0b5901c2e814$9e19dc00$32021aac@chad>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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