简体   繁体   English

在子查询中按属性过滤边 - orientdb sql

[英]Filter edges by property in a subquery - orientdb sql

I have the following OrientDB SQL query that returns the username and country of all the friends of user #12:0 .我有以下 OrientDB SQL 查询,它返回用户#12:0的所有朋友的用户名和国家/地区。

select 
   username, country 
from (select 
         expand( both('friends') ) 
      from 
         users 
      where 
         @rid = #12:0)

But, the friends edge has a property years with an integer.但是, friends边缘有一个整数years的属性。 I only want those friends of #12:0 that have friends.years > 3 .我只想要那些拥有friends.years > 3#12:0 friends.years > 3

I have tried我试过了

SELECT username, country from (SELECT expand(outE('friends')[years > 3].inV()) FROM #12:0)

SELECT username, country from (SELECT expand(both('friends')[years = 2]) FROM #12:0)

and various plays on the same query.以及对同一查询的各种播放。

Thanks, all!谢谢大家!

create class User extends V
create property User.username string
create property User.country string

create class friends extends E
create property friends.year integer  


create vertex User content {'username':'u1', 'country':'PT'}
create vertex User content {'username':'f1', 'country':'AW'}
create vertex User content {'username':'f2', 'country':'CN'}

create edge friends 
from (select from User where username = 'u1')
to (select from User where username = 'f1')
content {'years':3}

create edge friends 
from (select from User where username = 'f2')
to (select from User where username = 'u1')
content {'years':4}

I believe this is your situation.我相信这就是你的情况。 You can:你可以:

select expand(bothE('friends')[years = 3].inV()) 
from (select from User where username = 'u1')

But, for what I know, the following is not yet supported:但是,据我所知,尚不支持以下内容:

select expand(bothE('friends')[years > 3].inV()) 
from (select from User where username = 'u1')

Another option is to wrap the core query with another nested query:另一种选择是用另一个嵌套查询包装核心查询:

select * from (
select expand(both('friends')) 
from (select from User where username = 'u1')
)
where years > 3

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

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