Search code examples
propertiesorientdb

Select property from a link property in OrientDb


In OrientDB, I have a class "V_MyClass", and a property of type "link" to the class V_User ("createdBy"). Both extend V. In this moment, I have a query which returns all elements from class.

select from MyClass

"createdBy" is something like "#1:11". V_User has a property like "username". I want to add "username" for "createdBy", in this select.

The SQL version is: - current query:

select * from MyClass

- requested query:

select m.*, u.username from myclass m inner join user u on m.createdBy = u.id

I want to reproduce the same query in OrientDB. Note that createdBy is not an edge, but a "link" property.


Solution

  • You could use this query

    select *,createdBy.username from V_MyClass
    

    Hope it helps.