I have the following OrientDB SQL query that returns the username and country of all the friends of user #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. I only want those friends of #12:0
that have 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')