-2

I want to make a batch query similar to this:

SELECT name FROM user 
WHERE uid IN (userID1, userID2, userID3 ...) and name LIKE '%searchParameter%'

Is this even possible? And how can I achieve this?

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99
maaizle
  • 135
  • 1
  • 11
  • What is your actual problem – query the user table by user id, as stated in your question title, or the “LIKE”-like search? FQL does not have a LIKE operator. There are some basic string operators, but I don’t know if you can use them for that kind of search. But if you already have the user ids, why would you query by name as well – do you want to limit the results, so that you do not get a result for each id? – CBroe Nov 19 '12 at 13:51
  • Exactly your last point. I have an app where users can search for other users of the app (based on their names) but I have the IDS and because pulling all the names with IDS will be a bit intensive, I was wondering if I could use the LIKE operator like in sql. Anyway can u give me an example of how to fetch the names based on uid in one single batch query (forgetting the LIKE operator)? – maaizle Nov 20 '12 at 10:53
  • What do you mean by batch query in this case? The query you got will already give you the names of the users with the specified ids, right? And you can filter for user names by adding `STRPOS(name, 'Foo') >= 0` to your WHERE condition. (Warning, this seems to be case-sensitive.) – CBroe Nov 20 '12 at 10:58
  • What I meant was that I have no idea how to do this in FQL. The above statement is written in SQL as u can see. Am a C# developer and a beginner too. I was wondering if u could give me some direction on how to achieve this. Any language will be good, I can try to translate it later. – maaizle Nov 20 '12 at 11:08

1 Answers1

0

Yes it is possible

SELECT name, uid from user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me()) and strpos(lower(name),lower('Zuck')) >= 0

In the case above I'm querying for names from friends that include the letters zuck

http://developers.facebook.com/docs/reference/fql/user/

phwd
  • 19,975
  • 5
  • 50
  • 78