FQL SELECT query with IN ,NOT Keyword

倖福魔咒の 提交于 2019-12-04 04:57:19

问题


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)

Retrieve every one expect those people who are in $x.

This is giving me an fatal error Uncaught Exception: 601: Parser error: unexpected 'NOT

Thanks in advance!


回答1:


You can use WHERE NOT (columnName IN (things 'not in')

Like this example :

SELECT post_id, message
 FROM stream 
 WHERE source_id IN ( SELECT page_id 
                        FROM page 
                       WHERE name='coca-cola'
                    ) 
   AND NOT (message IN ( 'probando cocacola'
                       , 'Stijn '
                       , 'Ha ha ha me crezy hu'
                       , ''
                       )
           )
LIMIT 50



回答2:


"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.



来源:https://stackoverflow.com/questions/8308473/fql-select-query-with-in-not-keyword

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!