May 2011
Beginner
408 pages
10h 27m
English
Sometimes you need to combine tables to get the data you need. Facebook provides a great example in its Developer documentation that gets all the information about a user and his or her friends:
SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2
FROM friend WHERE uid1 = me())
This query returns, in XML or JSON format, an object including a list of IDs, names, and pictures for the currently logged-in user and his friends. Notice the subselect, which pulls a list of IDs from the friend table that have a friend as the currently logged-in user. You'll use this often in your FQL, so get used to subqueries and sometimes multiple subselects.
Read now
Unlock full access