现在有表friend
字段 ----id 主键 userid 用户ID friendId 好友ID用户A 有好友 b c d
现在我想为A推荐好友,需要查询 b 。c 。d的所有好友,但是,这些好友不能是A的好友该怎么办啊~~~
字段 ----id 主键 userid 用户ID friendId 好友ID用户A 有好友 b c d
现在我想为A推荐好友,需要查询 b 。c 。d的所有好友,但是,这些好友不能是A的好友该怎么办啊~~~
select * from tbl where not exists(子查询语句)
where userid in (select friendId from friend where userid='a')
and t.userid !='a'
select id,userid,friendid from friend where b.userid in (select friendid from tb where userid=a) and friendid not in (select friendid from tb where userid='a'