FQL SELECT query with IN ,NOT Keyword

前端 未结 2 468
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-22 17:04

I\'m trying to retrieve all my friends expect few people.

I formed the query like this

    SELECT uid,name FROM user WHERE uid NOT IN ($x)
2条回答
  •  余生分开走
    2021-01-22 17:32

    "NOT IN" is not a supported feature of FQL. Ref: http://forum.developers.facebook.net/viewtopic.php?id=1420

    I would suggest using something like this to get all of your friends:

    SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
    

    And then in your script when this returns ignoring those you don't want, assuming you are using php something like:

    foreach( $result['data'] as $row )
    {
      if( !in_array($row['uid'], $x) // do stuff
      else // ignore
    }
    

    Hope that helps.

提交回复
热议问题