1

I want to fetch the data from Facebook user table using wild cards. But, I guess current FQL is not supporting the wildcards, or I'm missing something.

Also, it gives an error for LIKE as well.

currently, I'm executing it as follow

SELECT uid, username,first_name,last_name FROM user WHERE first_name LIKE '%ab%' order by first_name LIMIT 0,20;

I tried *, ?, _ etc.

Still, i couldn't get it yet.

Any suggestions?

kaur
  • 567
  • 1
  • 7
  • 24

2 Answers2

2

There's a way to do something similar, but even then you can't ask such a question from the api.

Here's a "working" version of your query:

SELECT uid, username, first_name, last_name
FROM user
WHERE strpos(lower(first_name), 'ab') >= 0
ORDER BY first_name
LIMIT 0,20

The problem with this query is that it produces this error:

Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql

You basically don't have a way to ask for all users, just based on specific user(s), for example this works:

SELECT uid, username, first_name, last_name
FROM user
WHERE strpos(lower(first_name), 'ab') >= 0 AND uid IN ("user_id_1", "user_id_2", ...,"user_id_n")
ORDER BY first_name
LIMIT 0,20
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • Thank you Nitzan. I basically have the same kind of query. SELECT uid, username,first_name,last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) and strpos(lower(first_name), 'ab') order by first_name LIMIT 0,20; But still it is not giving the desired results. 'ab' or any other value doesn't have any effect. – kaur May 30 '12 at 03:15
  • You forgot the `>= 0` part, it should be: `SELECT uid, username,first_name,last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) and strpos(lower(first_name), 'ab') >=0 ORDER BY first_name LIMIT 0,20;` – Nitzan Tomer May 30 '12 at 05:36
1

FQL doesn't support the LIKE operator. You can use the supported strpos function to perform partial string searches on supported table indices, however none of the name fields on the user table are indexable.

Jesse Proulx
  • 821
  • 7
  • 13