I have two tables Person and Interest
Person table structure
Id | Name
Interest table structure
Id | Person Id | Interest Category
My question is how do I get person who have a liking for the category ‘music’ AND ‘movie’ AND ‘sport’. The category will be dynamically.
So it will like using IN operator but by using AND condition not OR condition in the IN operator.
SELECT `Person Id` FROM Interest
WHERE `Interest Category` IN ('music', 'movie', 'sport');
You could use
HAVING COUNT. The number would have to be dynamically too.