尝试这样的事情,我在查询中评论,所以请让我知道,如果它会给你一个如何使用它的想法。
这将选择不同的用户id,这些id与使用过滤器提供的所有语言的所有用户相匹配。可以在select子句中检索更多的列,但还需要在GROUPBY子句中使用相同的列。
select u.user_id from users as u
inner join users_language as ul
on ul.user_id = u.user_id
where ul.language_id in (1, 6, 7, 11) # IDs of the languages, you can continue the WHERE clause here by adding AND appending your different cases.
group by u.user_id
having count(ul.language_id) = 4; # number 4 comes from the total count of languages in the IN clause. I have 4 ids there, hence 4 here.