SQL question
Sims, John
ayu8 at cdc.gov
Wed Nov 30 09:46:44 CST 2005
> -----Original Message-----
> From: valentina-bounces at lists.macserve.net
> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of
> Florian Bogeschdorfer
> Sent: Tuesday, November 29, 2005 2:33 PM
> To: 'Valentina Developers'
> Subject: SQL question
>
> Hi all!
>
> Say I have two tables:
>
> TABLE CUSTOMER with fields ID,NAME,ADRESS
>
> And
>
> TABLE PAYBACKCARD with fields CUSTOMER_ID,ID,CARDNUMBER
>
> If I search for customers with cards, I do "SELECT * FROM
> CUSTOMER,PAYBACKCARD WHERE CUSTOMER.ID=PAYBACKCARD.CUSTOMER_ID"
>
> Fine. But now I want to find all customers WITHOUT card. How
> can I do this?
> In this case there is no link between the two tables, I need
> "SELECT * FROM CUSTOMER WHERE there is no link between the tables..."
>
> TIA
>
> Florian
>
Hi Florian,
I'm not 100% sure that Valentina supports this, but the most common way
I know of would be...
SELECT * FROM Customer WHERE NOT Customer.ID IN (SELECT Customer.ID FROM
Customer,PaybackCard WHERE Customer.ID=PaybackCard.Customer_ID)
If that doesn't work, look into the EXISTS keyword of SQL.
Good luck.
-John
More information about the Valentina
mailing list