简体   繁体   English

Arango AQL 查询不在

[英]Arango AQL queries NOT IN

I'm creating a Facebook-like website and I want to suggest friends for a user who studies at the same school, but are not already friends.我正在创建一个类似 Facebook 的网站,我想为在同一所学校学习但还不是朋友的用户推荐朋友。

I already Trying to do this with AQL queries, but there seems to be a syntax problem..我已经尝试使用 AQL 查询来执行此操作,但似乎存在语法问题..

The error code return was:错误代码返回是:

syntax error, unexpected identifier near 'user._key not in (for friend in...' at position 3:3 (while parsing)语法错误,'user._key not in (forfriend in...' at position 3:3 (解析时)

for user in users
  filter user._key != "myself"
    user._key not in (for user in 1..1 outbound "users/myself" friendship return user) 
      user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
    return user

If you want to apply several filter criteria you have to combine them via logical AND (or the && operator)如果您想应用多个过滤条件,您必须通过逻辑AND (或&&运算符)将它们组合起来

FOR user IN users
  FILTER user._key != "myself" AND
    user._key not in (for user in 1..1 outbound "users/myself" friendship return user) AND
    user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
  RETURN user

or you can use separate FILTER clauses或者您可以使用单独的 FILTER 子句

FOR user IN users
  FILTER user._key != "myself"
  FILTER user._key not in (for user in 1..1 outbound "users/myself" friendship return user)
  FILTER user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
  RETURN user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM