Time for action – getting it down to one API call

  1. There's another way to use the IN operator:
    SELECT name
    FROM user
    WHERE uid IN (
      SELECT uid2 
      FROM friend 
      WHERE uid1 = «user's ID»
    )
  2. Again, the whitespace doesn't matter, and is only to help readability; you can call it in a single line like so:
    SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='123')
  3. Try it out using an API URL.

What just happened?

The query inside the parentheses is called a "sub-query." Essentially we are making FQL do the same thing we just did with AS3: retrieve a list with one query and use it in another query.

Have a go hero – Mutual friends

I want to issue you the challenge of writing a query that gets all the mutual friends of two users: the logged-in user, ...

Get Facebook Graph API Development with Flash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.