I have a table with the columns response_id, question_id and answer_id.
I would like to find all response_id matching multiple conditions. For example the following are some usecases
- User selected answer 1 for question 1 and answer 2 of question 2
- User (selected answer 3 for question 1 and answer 2 for question 2) or answer 1 for question 3
In SQL, I can do this using INTERSECT and UNION but the INTERSECT is not available in MySQL. Can someone guide me how to solve this problem?
example in SQL, which is needed in MySQL.
select distinct(response_id) from table where question_id = 873 AND answer_id = 5269
intersect
select distinct(response_id) from table where question_id = 874 AND answer_id = 5273
intersect
select distinct(response_id) from table where question_id = 877 AND answer_id = 5286