例子:我想谁不遵循ID 2用户得到所有用户谁没有关注用户2
表关注
id | user_id | follower_id
1 2 7
2 2 8
表用户的所有用户
id | username | e-mail | group
例子:我想谁不遵循ID 2用户得到所有用户谁没有关注用户2
表关注
id | user_id | follower_id
1 2 7
2 2 8
表用户的所有用户
id | username | e-mail | group
给这一个镜头:
Select users.*
from users
where users.id not in (
select followers.follower_id
from followers
where followers.user_id = "2"
)
谢谢,完美工作! –
请接受这个答案作为正确的答案。谢谢。 – RLessard
我不是一个mysql专家,但我相信一个伪sql将是:
select users.* from users where users.id is in (select distinct follower_id from followers where followers.user_id != 2)
该!=意味着不同。
结果返回多个用户重复 https://image.prntscr.com/image/T-iRabAaQg_9Jzshg02luQ.png –
我已经改变了伪sql。 – srodriguex
您可以使用** distinct **删除重复项。 – srodriguex
你不应该详细的语言你所期望的答案:SQL或PHP方式。 – srodriguex