Re: Novice needs help - Mailing list pgsql-sql

From Chad Thompson
Subject Re: Novice needs help
Date
Msg-id 0b5901c2e814$9e19dc00$32021aac@chad
Whole thread Raw
In response to Novice needs help  (Terry Lee Tucker <terry@esc1.com>)
List pgsql-sql
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)
>



pgsql-sql by date:

Previous
From: jasiek@klaster.net
Date:
Subject: Re: Novice needs help
Next
From: patrick
Date:
Subject: converting time_t to timestamp?