且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL-选择具有覆盖一组值的组

更新时间:2023-01-31 14:10:43

这是组内查询"的示例.我喜欢使用group byhaving解决它们,因为这是非常灵活的:

This is an example of a set-within-sets query. I like to solve them using group by and having, because this is a very flexible:

SELECT user_id
FROM action a
WHERE action_type IN (0, 3, 4, 5)
GROUP BY user_id
HAVING COUNT(DISTINCT action_type) = 4;