Search code examples
orientdb

In a OrientDB query, how can the where clause reference a column in the select


I want to write a query in OrientDB performs WHERE filtering on some columns/fields on the SELECTed vertex.

Here is the equivalent query implemented with nested SELECT's-

SELECT FROM (SELECT EXPAND(OUT('Foo')) FROM  #13:1 )  WHERE prop = 'bar'

How I can write this query with a single SELECT?


Solution

  • create class Foo extends E
    
    create vertex                                  #9:0
    create vertex set prop = 'bar'                 #9:1
    create vertex set prop = 'baz'                 #9:2
    
    create edge Foo from #9:0 to #9:1
    create edge Foo from #9:0 to #9:2
    

    You can:

    select expand(out('Foo')[prop = 'bar']) from #9:0