I have an FQL query that is returning the list of people who have commented on a post:-
SELECT time, fromid, likes, post_id_cursor from comment where post_id = '331288023558058_592220760798115' ORDER BY time DESC LIMIT 5000
What I'd like to do is to include another query within this query to return more details of the person leaving a comment
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}
Is it possible to combine the queries so that I get all the data in a single query? Any ideas how?
Thanks
Jonathan
use multiqueries
commentquery = "SELECT time, fromid, likes, post_id_cursor from comment where post_id = '331288023558058_592220760798115' ORDER 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)
To user multiple FQL queries, you need to json_encode the queries in an array. for the /fql?q= parameter
So to specify:
$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