Queries are of the form SELECT [fields] FROM [table] WHERE [conditions]. Unlike SQL, the FQL FROM clause can contain only a single table. You can use the IN keyword in SELECT or WHERE clauses to do subqueries, but the subqueries cannot reference variables in the outer query’s scope.
FQL can handle simple math, basic boolean operators, AND or NOT logical operators, and ORDER BY and LIMIT clauses. For any query that takes a uid, you can pass me() to return the logged-in user.
Other functions that are available are now(), rand(), concat(string, …), strlen(string), substr(string, start, length), strpos(haystack, string), contains(string), upper(string), lower(string), and distance(latitude, longitude, “float”, “float”).
The FQL component of Facebook’s API is powerful but it can be difficult to find useful examples. The following is a compiled list of queries that I found to be useful and interesting. Feel free to test them with the Facebook Graph API Explorer. If these examples have helped you, please like my page and follow me on twitter (links below). If any FQL is broken or unclear, let me know.
Last Updated: December 3, 2013