我有一个FQL查询返回对帖子发表评论的人员列表: -
SELECT time,fromid,likes,post_id_cursor from comment where post_id ='331288023558058_592220760798115'ORDDER BY time DESC LIMIT 5000
我想要做的是在此查询中包含另一个查询,以返回留下评论的人的更多详细信息
SELECT sex,first_name,middle_name,last_name,username,locale,profile_url,pic_square_with_logo FROM user WHERE uid = {fromid of person leaving comment}
是否可以组合查询以便在单个查询中获取所有数据?有什么想法吗?
由于
乔纳森
答案 0 :(得分:1)
使用多个查询
commentquery =“SELECT time,fromid,likes,post_id_cursor from comment where post_id ='331288023558058_592220760798115'ORDDER BY time DESC LIMIT 5000”
userquery = SELECT sex,first_name,middle_name,last_name,username,locale,profile_url,pic_square_with_logo FROM user WHERE uid =(SELECT fromid FROM #commentquery)
要使用多个FQL查询,您需要对数组中的查询进行json_encode。对于/ fql?q =参数
所以要指定:
$queries = [];
$queries['comments'] = "SELECT time, fromid... ";
$queries['users'] = "SELECT sex, ... WHERE uid IN (SELECT fromid FROM #comments)";
$fql = json_encode($queries);
// then using curl or whatever
// (multiqueries don't work with PHP sdk's $facebook->api() i believe)
GET http://graph.facebook.com/fql?q=$fql
答案 1 :(得分:1)
使用多重查询
graph.facebook.com/fql?q={"query1":"SELECT time, fromid, likes, post_id_cursor from comment where post_id = '331288023558058_592220760798115' ORDER BY time DESC LIMIT 5000","query2":"SELECT sex, first_name, middle_name, last_name, username, locale, profile_url, pic_square_with_logo FROM user WHERE uid IN (SELECT fromid FROM #query1)"}
答案 2 :(得分:0)
您可以在此处找到答案:fql join; can i join two tables with FQL?
您想要使用多个查询加入这两个查询。希望有所帮助。