我具有以下OrientDB SQL查询,该查询返回用户#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