21,886
社区成员
发帖
与我相关
我的任务
分享
select * from `表` where `user_id`='你的id' and `follow_user_id`='某个用户id' and `user_id` in (select `follow_user_id` from `表` where `user_id`='某个用户id')
第4条少了一个and,重新写一下user_id follow_user_id
1 2
1 3
1 4
按 user_id 分表后,你整检查所有的表才能得到与 follow_user_id 相连的 user_id
所以你需要另有一组以 follow_user_id 分组的表
follow_user_id user_id
2 1
3 1
4 1