问题描述:

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)
相关阅读:
Top