这是我的表 following
现在我想找到用户 1 也关注的用户 1 的关注者列表
id | user | follower
-----------------------
1 | 1 | 2
2 | 2 | 1
3 | 1 | 3
4 | 3 | 1
例如我想找到也关注我的关注者列表
最佳答案
与 EXISTS :
select t.follower from tablename t
where
t.user = 1
and exists (
select 1 from tablename
where user = t.follower and follower = t.user
)
参见 demo .
结果
| follower |
| -------- |
| 2 |
| 3 |
关于mysql - 如何判断两个人是否互相关注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55403964/