What functions and operators are supported in FQL?
FQL supports a number of functions that will be very familiar to PHP developers (see Table 8-1).
Table 8-1. FQL functions
Returns the current time
Generates a random number
Returns the length of the string
Concatenates strings together
Returns the specified substring
Returns the position of the needle in the haystack
Converts the string to lowercase
Converts the string to uppercase
The standard set of SQL-like operators are supported: =, >=, <, etc., parentheses for order of operations, and the arithmetic operators +, -, *, and /. FQL also supports the AND, OR, and NOT logical operators inside of queries.
You can use the functions directly inline with your FQL queries:
SELECT upper(concat(first_name, " ", substr(last_name, 0, 1), ".")), birthday FROM user WHERE sex = "female" AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user) LIMIT 5;
That may not be the most practical query ever constructed, but
it will return
user’s first five
female friends with their first name and last name’s first initial in
all caps. Do with it what you will.