例子:我想誰不遵循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