Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 164

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 167

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 170

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 173

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 176

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 178

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 180

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 202

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 206

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 224

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 225

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 227

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/includes/class.layout.php on line 321

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 56

Warning: Creating default object from empty value in /home/ibrfao/masteringapi.com/blog/wp-content/themes/platform/admin/class.options.metapanel.php on line 49
Back to top"/> Facebook FQL: How To Search Partial Strings (Similar To MySQL Like Operator) | MasteringAPI

Wondering if the FQL has an operator similar to the MySQL LIKE operator to do string search operations?

FQL does have a similar functionality:

Other functions that are available are now(), strlen(), substr() and strpos().

The function we need is the strpos() function and here how to use it:

SELECT name 
FROM user 
WHERE uid IN (
	SELECT uid2 
	FROM friend 
	WHERE uid1=me()
)
AND strpos(lower(name),"jo") >=0

The above will match all your friends where the name field contains the letters “jo” (“Joe, John, Joseph…etc”).

Notes to consider:

  • To do case-insensitive search, use the lower() method and make sure that the second parameter (the search value or “jo” in the example above) is also using small letters
  • Note the >=0 bit, this is mandatory to get the expected results !
  • When a field is used in the strpos() function, it’s no longer treated as an indexable field!
  • Use the fql.query Test Console to test your queries
Back to top
Tagged with:
 
  • http://onitsukatiger.lah.cc/ Lynn

    Perfect advice! I have already been seeking something similar to this for a long time now. Cheers!

  • http://www.facebook.com/people/Daniel-Sailes/100001900043206 Daniel Sailes

    haha, thankyou mate. this website has worked wonders for me the past few daws :D

  • None

    Where is this documented?