Re: Novice needs help

From: "Chad Thompson" <chad(at)weblinkservices(dot)com>
To: "Terry Lee Tucker" <terry(at)esc1(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Novice needs help
Date: 2003-03-11 21:24:32
Message-ID: 0b5901c2e814$9e19dc00$32021aac@chad
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)esc1(dot)com>
To: <pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org)
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message patrick 2003-03-12 02:57:04 converting time_t to timestamp?
Previous Message jasiek 2003-03-11 21:03:20 Re: Novice needs help