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?...
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.
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()
))
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.