我对这个fql.query方法有一些问题:
select music
from user
where uid = ......
and music in (select music
from user
where uid = ......
)
我想获得两个用户之间共同的音乐兴趣;它适用于像这样的查询
select uid
from user
where uid = ......
and uid in (select uid
from user
where uid = ......
)
我认为问题是第二个查询返回一个整数,第一个返回一个字符串数组。任何人都可以帮我这个吗?
(请原谅我糟糕的英语!我来自西班牙;))
答案 0 :(得分:0)
第一个查询是否已经为您提供了答案?
我的意思是它执行以下操作:
-- Display only music field
select music
from user
where uid = <first_USER> -- Selection of your first user
and music in ( -- We want to macth the string with another
select music -- Selects only the music field
from user
where uid = <second_USER> -- Selection of your second user
)
因此,您获得了两个用户记录中匹配的音乐名称。
你的第二个问题对我来说有点奇怪:
select uid
from user
where uid = <first_USER?>
and uid in (select uid
from user
where uid = <second_USER?>
)
其中基本上转换为找到user_id匹配用户1和用户2。事情永远不会发生,因为每个用户都拥有自己的uid。
顺便说一句,我不知道facebook如何处理音乐字符串,但似乎用户不会以常见的拼写和/或格式编写自己喜欢的音乐名称。这可能会妨碍您的匹配系统。
答案 1 :(得分:0)
我试过了:
select music
from user
where uid=UID1
AND music IN (SELECT music from user where uid=UID2)
当UID1 music
字符串与UID2的字符串完全匹配时,它可以正常工作。