ukr_bend@yahoo.com wrote:
> Thanks Bill. Could be the solution. But what I need are rows that only
> meet all 4 conditions of the where statement. But like you said,
> perhaps retrieve everything then do the grunt work in the app.
There's a HAVING COUNT technique that I have seen used, but I have
always thought it is kind of delicate and too easy to get wrong.
SELECT pref.userid FROM userpref AS pref
WHERE ( pref.questionid = '30' and pref.answer = '7507' )
OR ( pref.questionid = '41' and pref.answer = '9108' )
GROUP BY userid
HAVING COUNT(*) = 2
Change the value 2 to another value, matching the number of questionid
terms you have in your WHERE clause.
Regards,
Bill K.