I have a yable for members and a table for the services that each member provides:
MemberID | ServiceID
--------------
1 | 2
1 | 3
2 | 1
2 | 3
So a member can provide any number of services.
I have a search form which lets the user check some or all of the services. I want to be able to select all of the members that provides ALL of the services that the user selected (and not just some of them). I used WHERE ... IN.., but it returns all of the members that provides at least one of the selected services.
I now have a query similar to:
SELECT members.id
FROM
members
LEFT JOIN services ON (members.id=services.memberID)
WHERE members.id IN (....)
Any help?
Thank you
If I understand your question correctly, this should work:
where (…) is a list of all the selected servicesIDs, and x is the number of items in (…)