how to limit query in OrientDB by two input params

84 Views Asked by At

I've got the following structure in DB:

class(V): @city (Name, X, Y)
class(V): @route(Name)
class(V): @Alternative_Route(Name) extends from @route

class(E): @has_route_to 
class(E): @has_subroute

The Edges are connected to the Vertices like this:

city -> has_route_to -> route -> has_route_to -> city
route -> has_subroute -> city 

As input I've got two points: City1 and City2.
For intance I need to see what subroutes we have between City1 and City2.
I'm writing the following query:

traverse outE('has_route_to'), has_route_to.in 
from 
(select * from City where Name = 'City1')

But if I execute it I'll see all routes from City1, not only from City1 to City2.

It is possible to say to OrientDB: show me all points between City1 and City2 only?

1

There are 1 best solutions below

1
On BEST ANSWER

Try this:

select from route where (Name in (select both('has_route_to').Name from City where Name = "City1")) and (Name in (select both('has_route_to').Name from City where Name = "City2"))

Hope it helps

Regards