示例:我想让所有不关注id 2用户的用户
表追随者
id | user_id | follower_id
1 2 7
2 2 8
表用户
id | username | e-mail | group
答案 0 :(得分:0)
我不是mysql专家,但我相信伪sql会是:
select users.* from users where users.id is in (select distinct follower_id from followers where followers.user_id != 2)
!= 表示不同。
答案 1 :(得分:0)
试一试:
Select users.*
from users
where users.id not in (
select followers.follower_id
from followers
where followers.user_id = "2"
)