Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workaround for subquery

Status
Not open for further replies.

NetworkHound

Programmer
Sep 23, 2003
2
GB
I am porting a project to MySql 4.0 and can't use the following query which is designed to return a list of options that have not been selected by a particular customer.

SELECT OptionID from OptionLookUp
WHERE NOT EXISTS
(SELECT *
FROM CustomerOptionsTable
WHERE CustomerOptionsTable.OptionID=OptionLookUp.OptionID
AND CustomerOptionsTable.CustomerID=7689)

Can anyone suggest a workaround that will return either :

1) the same result

or

2) a recordset that includes all available options and distinguishes between selected and unselected options for the particular customer.

All help gratefully received.
 
Thanks for the response.

I have checked out the manual but the code snippet

SELECT table1.* FROM table1
LEFT JOIN table2 ON table1.id=table2.id
WHERE table2.id IS NULL;


doesn't really deliver the results I need. In the CustomerOptionsTable there are a few rows relevant to a particular customer showing the options he has selected. I need to identify the unselected options for that customer only.

I can't work out how to modify the code in the manual to make it specific to one customer. As given it just returns nothing as every option has been selected by somebody.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top