FQL NOT IN Equivalent operator like <> , EXCEPT, !=

喜夏-厌秋 提交于 2019-12-23 02:16:30

问题


I'm trying to develop this code:

$users = $facebook->api(array(
  'method' => 'fql.query',
  'query' =>    "SELECT uid, last_name, pic_big"
             + " FROM user WHERE uid IN ("
             + "     SELECT uid" 
             + "     FROM page_fan"
             + "     WHERE page_id='411133928921438'" 
             + "         AND uid IN ("
             + "             SELECT uid2 FROM friend WHERE uid1 = me()"
             + "         )"
             + ")"
));

The idea is that i don't want to use the operator IN but NOT IN, but FQL doesn't support operators like NOT IN, EXCEPT... How can i do it with FQL?...


回答1:


There is no NOT IN operator in FQL. You could do a simple select using IN and use PHP for negation. It's a little overhead, but as far as I know it's the only way.

I found a related post: link here.




回答2:


Facebook does support NOT IN. You just have to wrap it in enough parantheses.

For example, to find the users attending an event who are not the current user or friends wth the current user:

SELECT uid, name FROM user WHERE uid IN (
  SELECT uid FROM event_member WHERE eid=209798352393506
)
AND NOT (uid=me())
AND NOT (uid IN (
  SELECT uid1 FROM friend WHERE uid2=me()
))



回答3:


Just found a way to do NOT IN and had to share the happy news ;)

SELECT post_id, actor_id, message FROM stream WHERE source_id in(a, b, c) and NOT (actor_id in (a, b, c))

This will get the messages from multiple pages by unkown users, i.e. all posts by users or pages that are not the pages themselves, aka fans.



来源:https://stackoverflow.com/questions/10519823/fql-not-in-equivalent-operator-like-except

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