Re: Grab data WHERE table.ID NOT LIKE otherTable.ID

From: Nils Zonneveld <nils(at)mbit(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Grab data WHERE table.ID NOT LIKE otherTable.ID
Date: 2001-07-07 11:00:44
Message-ID: 3B46EBD8.AB262046@mbit.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Mark G. Franz" wrote:
>
> Here is my SQL;
>
> "SELECT Registration.CustomerID, Customer.CustomerID AS CustID, Firstname,
> Lastname, Username, Password, Question, Answer, Email, Age, Gender, Address,
> City, State, Zip FROM Customer, Registration WHERE Customer.CustomerID NOT
> LIKE Registration.CustomerID"
>
> I'm trying to return all the records from Customer that have not registered
> in Registration, so the psuedo sql would read;
>
> Return everything from all fields in Customer where the ID is NOT in the
> Registration table. Any ideas?
>
> Thanks,
>
> Mark

Try the NOT EXISTS operator:

SELECT Customer.CustomerID AS CustID, Firstname, Lastname, Username,
Password, Question, Answer, Email, Age, Gender, Address, City, State,
Zip
FROM Customer
WHERE Customer.CustomerID
NOT EXISTS (SELECT *
FROM Registration
WHERE Registration.CustomerID = Customer.CustomerID);

Hope this helps,

Nils Zonneveld
--
Alles van waarde is weerloos
Lucebert

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-07-07 12:20:13 Re: pg_dump error message
Previous Message Joseph 2001-07-07 10:52:07 pg_dump error message