Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:07:41+00:00 2026-05-27T00:07:41+00:00

I’m attempting to do a Facebook FQL Multiquery (via JS SDK FB.api call) to

  • 0

I’m attempting to do a Facebook FQL Multiquery (via JS SDK FB.api call) to load a single photo for each of 10 random Facebook friends where they have been tagged (aka “Show 10 random friends and a photo of theirs”). Here is my Javascript array of queries:

   var queries = {
            q1:"SELECT uid, name FROM user WHERE uid IN (Select uid2 from friend where uid1 = " + user_id 
                 + " order by rand() limit 10) ",
            q2: "SELECT pid, subject from photo_tag where subject in (SELECT uid from #q1) limit 10",
            q3:"SELECT src from photo where pid in (SELECT pid from #q2)"};

What I was trying to do:

  1. Query 1: Get the userid and name of 10 random friends of the user.
  2. Query 2: Get the photo id and subject name of phototags where the user ids matched those from query 1.
  3. Query 3: Select the image src from the photos that matched those in query 2.

The problem is that I have no way in Query 2 to select DISTINCT records by users. That is, I cannot tell Facebook to return just a single photo for each user. Right now, it is arbitrary and all 10 rows could be different photo tags of the same user.

I could do some looping in Javascript and make a single FQL query for a pic for each matched user, but that just seems wrong. Any other suggestions on how to do this efficiently, preferably directly in FQL?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:07:41+00:00Added an answer on May 27, 2026 at 12:07 am

    Well, I solved this awhile back and am closing this for completeness.

    What I had to do was NOT do it all in a single multiquery. I had to FIRST make a single query to retrieve some random friends, THEN make a multiquery where we load a random photo for each of these friends.

    FB.api(
            {
                method: 'fql.query',
                query: "SELECT uid, name FROM user WHERE uid IN (Select uid2 from friend where uid1 = " + user_id 
                     + " order by rand() limit 8) "
            }, function (response) {
                var queries = {};
                for (x in response) {
                    if (typeof photoArray[response[x].uid] == 'undefined') photoArray[response[x].uid] = [];
                    photoArray[response[x].uid]['name'] = response[x].name;
                    queries[response[x].uid] = "SELECT src_big, caption from photo where pid in (SELECT pid from photo_tag where subject =" + response[x].uid + " order by rand() limit 1) ";
                }
    
                FB.api(
                    {
                method: 'fql.multiquery',
                queries: queries
                    },
                    function(response) {
    
    
                        for (y in response) {
                            if (typeof response[y].fql_result_set[0] != 'undefined') {
                                photoArray[response[y].name]['image_src'] = response[y].fql_result_set[0].src_big;
                                            // Do what you want with the pics
                            }
                        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.