Home » Facebook » Facebook Query Language

Facebook Query Language

Tuesday, March 8th, 2011 | Facebook

The Facebook Query Language (FQL) is a SQL-style language specifically designed to
allow developers to interact with Facebook information. Facebook allows you to interact
with nine separate “tables” to query information directly. You have access to the following:
• user
• friend
• group
• group_member
• event
• event_member
• photo
• album
• phototag
I’ll get into the specifics of the information you have access to in these “tables” later in
the book, but suffice to say, Facebook exposes a lot of information to you for your
application. And, like most SQL implementations, some additional functions allow you to
take a few shortcuts when you request user information:
• now() returns the current time.
• strlen(string) returns the length of the string passed to the function.
• concat(string1, string2,…, stringN) concatenates N strings together.
• substr(string, start, length) returns a substring from a given string.
• strpos(haystack, needle) returns the position of the character needle in the string
• lower(string) casts the given string to lowercase.
• upper(string) casts the given string to uppercase.
To write FQL, you follow basic SQL syntax. For example, to extract my name and
picture from Facebook, you would write a simple query like so:

SELECT name, pic
FROM user
WHERE uid = 7608007
The previous snippet, when executed by the Facebook platform, will return a structure
(in a format that you define in your call) with a URL to the image of the profile image for
user 7608007. Calls like these are useful in giving you granular control of the information
you get back from the API.

Blog search terms:


Related Facebook Query Language

Latest Hyundai Hyundai equus Better Than Gene

Hyundai equus Better Than Genesis It was a big deal. Hyundai was emerging

How to get mesothelioma compensation

How to get mesothelioma compensation Asbestos advice, mesothelioma compensation and claims from UK

Crackdown on Social Media After Riots

Crackdown on Social Media After Riots The government is contemplating tactics against the

Manchester United Wins 20th English league ti

Manchester United surged closer to a 20th English league title on Sunday, opening