我的 SQL 数据库中有 2 个表:
用户:id |电子邮件 |宗教 |政治
兴趣:id |用户 ID |兴趣名称
给定一个 user1 id,找到至少有 1 个匹配兴趣的第二个用户的最佳方法是什么?另请注意,用户表中的宗教/政治也应用于此匹配。
感谢任何帮助, - 安迪
最佳答案
select * from users
where id in (
select id from interests where interest_name in
( select interest_name from interests where id = :current_user_id ))
关于sql - MySQL:寻找具有相似兴趣的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4915790/