diugalde - 1 month ago 15x

SQL Question

`Class A Vertex = [11, 21, 51, 31, 28]`

Class B Vertex = [10, 14, 4, 0]

Class C Vertex = [33, 45, 35, 37]

I have a query(Q) that filter vertex of class A:

`SELECT FROM A WHERE condition`

Let's say the result is [31, 28]

Now I need to filter all the vertex of class B that are related (must be an outgoing edge and may or may not be a direct relation) to at least one vertex inside the query(Q) result.

The result query should return [4, 0], because if you traverse from those vertex you will get to at least one of the desired vertex (31 or 28)

I'm not sure how to create the correct query and what is the most efficient way to do it in OrientDB. Thank you.

Answer

```
select from (traverse in() from (select from A where num in [31,28])) where @class='B'
```

substitute the `select from A where num in [31,28]`

with your query to get those results

Source (Stackoverflow)

Comments