【发布时间】:2016-06-07 20:01:06
【问题描述】:
我有 2 个这样的表:
用户:
user_id|用户名
兴趣:
user_id|interest_id|interest_name
例如“兴趣”是这样填写的:
123|1|Football
123|2|Swimming
123|3|Skiing
456|2|Swimming
...
现在我 (user_id 123) 已登录,我想知道谁和我一样有最共同的兴趣(按降序排列)。
结果应该是这样的:
User 1: 45 interests in common (and list them)
User 2: 23 interests in common (...)
User 3: 11 interests in common (...)
知道如何解决这个问题吗?
我可能会先将我的兴趣读入一个数组,然后再做一个循环之类的?
谢谢!
【问题讨论】:
-
你试过什么?请阅读What topics can I ask about 和How to ask a good question 和the perfect question SO 不是免费的编码或代码转换或教程或图书馆查找服务 你还必须表明你已经努力解决你自己的问题问题。
标签: mysql