当前位置: 动力学知识库 > 问答 > 编程问答 >

php - MYSQLI - Select users whom I didn't follow

问题描述:

I just want a code to select users whom I didn't follow yet.

members is a user table and follow is the table for follow

In members table

id is user's id

in follow table there id, user_one and user_two.

user_one is following user_two

so I want SQL to select all users whom I didn't follow, wish someone will help me

网友答案:

Let's try it like this. Change MyID for the actual value.

SELECT * FROM members
WHERE
id != MyID
AND id NOT IN (SELECT user_two FROM follow_table WHERE user_one = MyID)
分享给朋友:
您可能感兴趣的文章:
随机阅读: