使用 IN 、NOT 关键字的 FQL SELECT 查询

发布于 2024-12-18 18:43:44 字数 278 浏览 3 评论 0原文

我正试图找回我所有的朋友,除了少数人。

我形成了这样的查询:

    SELECT uid,name FROM user WHERE uid NOT IN ($x)

检索每个人期望那些在 $x 中的人。

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

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-12-25 18:43:44

您可以使用 WHERE NOT (columnName IN (things 'not in')

就像这个例子:

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

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
空‖城人不在 2024-12-25 18:43:44

FQL 不支持“NOT IN”功能。参考: http://forum.developers.facebook.net/viewtopic.php?id =1420

我建议使用这样的东西来获取你所有的朋友:

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

然后在你的脚本中,当它返回时忽略那些你不想要的,假设你正在使用 php 类似的东西:

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

希望有帮助。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文