By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

subquery?

P: n/a
I have a table like below and I want to find all customerid's that have a
Yes for both optinid 1 and 3 so I tried this but it doesn't work:

SELECT customerid
FROM optinsxcustomers
WHERE (optinid=3 AND optvalue=Yes)
AND (optinid=1 AND optvalue=Yes);
Table: optinsxcustomers

Field Name and Data Type:
customerid Text (an email address)
optinid Number
optvalue Yes/No

I have tried replacing "=" with "like", and many other combos and am
completely frustrated. Any help would be great. In help, they talk about
subqueries. Maybe I should do that? what are they?

thanks,
Kerri
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Kerri,

Take a very close look at your where clause. optinid CAN NOT = 3 and 1 at
the same time! What you want are the records where optinid is either 1 or 3
and optvalue is Yes. Try this:
Where (optinid =1 OR optinid = 3) And optvalue = Yes

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Kerri" <kerri_case [@] hotmail.com> wrote in message
news:yP********************@comcast.com...
I have a table like below and I want to find all customerid's that have a
Yes for both optinid 1 and 3 so I tried this but it doesn't work:

SELECT customerid
FROM optinsxcustomers
WHERE (optinid=3 AND optvalue=Yes)
AND (optinid=1 AND optvalue=Yes);
Table: optinsxcustomers

Field Name and Data Type:
customerid Text (an email address)
optinid Number
optvalue Yes/No

I have tried replacing "=" with "like", and many other combos and am
completely frustrated. Any help would be great. In help, they talk about
subqueries. Maybe I should do that? what are they?

thanks,
Kerri

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.