I have tables like: user(id, name), interests(id, interest) and users_interests(user_id, interest_id).
I want to find all users that have a given number of matching interests.
Let's say there are 4 users: (mike, andre, julian, john). 2 of them have 3 matching interests. For example, mike(music, sports, games), andre(music, sports, games). The other 2 users have different interests. I need a query that will give me all users with 2 matching interests (2 is variable). The result would be mike and andre.