SELECt id, nameFROM usersWHERe id IN ( SELECt friend_id FROM user_relationships WHERe user_id IN ( 1, 2 ) GROUP BY friend_id HAVINg COUNT(friend_id) >= 2)
或一次连接:
SELECt friend_id, nameFROM user_relationships r INNER JOIN users u ON r.friend_id = u.idWHERe user_id IN ( 1, 2 )GROUP BY friend_idHAVINg COUNT(friend_id) >= 2
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)