Follow_id 是被关注者的id
fan_id 是用户id
想查出用户没有关注的人的id
我只能想到这样写,但感觉效率有点低:
select * from studio_follow f where f.follow_id not in (
select f.follow_id from studio_follow f where f.fans_id = 3
)
用not exits 比用not in 好一些
select * from studio_follow f where f.fans_id <> 3