表“argument_user”
+-------------+----------+
| argument | user_id |
+-------------+----------+
| bike | 1 |
| flower | 2 |
| web | 1 |
| web | 2 |
| nature | 1 |
| nature | 2 |
| nature | 3 |
+-------------+----------+
我只想获得与用户 1 和 2 相同的参数>>“web”(没有“nature”)
+-------------+
| web |
+-------------+
现在我正在使用这个查询,但它是错误的,因为它返回了“web”和“house”。
select argument from argument_user
where user_id in ('1','2')
group by argument having count(distinct(user_id)) = 2
+-------------+
| web |
| nature |
+-------------+
我想用同一张桌子做一个连接,但我认为当用户更多时它太重了!不是吗?因此,可以使用大量“user_id”来轻松使用。