Re: Novice needs help

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: Terry Lee Tucker <terry(at)turbocorp(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Novice needs help
Date: 2003-03-11 20:46:14
Message-ID: 3E6E4B16.4060700@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I answered my own question. Yes, it can be done like this:

SELECT code, name, city, country, province FROM cust WHERE (country,
province) NOT IN
(SELECT country, code FROM province);

The query returned two cust records that had bogus province codes in
them. Very cool :o)

Terry Lee Tucker wrote:

> 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...
>

--
Sparta, NC 28675 USA
336.372.6812
http://www.esc1.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2003-03-11 20:59:07 Re: Novice needs help
Previous Message David Delorme 2003-03-11 19:39:10 The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard