在子查询中按 属性 过滤边 - orientdb sql
Filter edges by property in a subquery - orientdb sql
我有以下 OrientDB SQL 查询 returns 用户 #12:0
.
所有朋友的用户名和国家
select
username, country
from (select
expand( both('friends') )
from
users
where
@rid = #12:0)
但是,friends
边有一个 属性 years
是一个整数。我只想要 #12:0
的那些拥有 friends.years > 3
的朋友。
我试过了
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)
以及对同一查询的各种播放。
谢谢大家!
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}
我相信这是你的情况。您可以:
select expand(bothE('friends')[years = 3].inV())
from (select from User where username = 'u1')
但是,据我所知,尚不支持以下内容:
select expand(bothE('friends')[years > 3].inV())
from (select from User where username = 'u1')
另一种选择是用另一个嵌套查询包装核心查询:
select * from (
select expand(both('friends'))
from (select from User where username = 'u1')
)
where years > 3
我有以下 OrientDB SQL 查询 returns 用户 #12:0
.
select
username, country
from (select
expand( both('friends') )
from
users
where
@rid = #12:0)
但是,friends
边有一个 属性 years
是一个整数。我只想要 #12:0
的那些拥有 friends.years > 3
的朋友。
我试过了
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)
以及对同一查询的各种播放。
谢谢大家!
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}
我相信这是你的情况。您可以:
select expand(bothE('friends')[years = 3].inV())
from (select from User where username = 'u1')
但是,据我所知,尚不支持以下内容:
select expand(bothE('friends')[years > 3].inV())
from (select from User where username = 'u1')
另一种选择是用另一个嵌套查询包装核心查询:
select * from (
select expand(both('friends'))
from (select from User where username = 'u1')
)
where years > 3