Search code examples
graph-databasesorientdb

Select certain properties (fields) when using BOTH in Orient SQL


Using OrientDB 2.* with OrientSQL.

I have a simple graph with Class Users that has a number of properties (username, country, pets, etc). Each user also has outgoing friends edge. I want to select only the username and country from all users who are friends with a specific user.

My query so far:

SELECT EXPAND( BOTH('friends') ) FROM users WHERE @rid = #12:0

returns the full user objects for those who are friends of #12:0

I want only to return the username and country of those friends.

Am I missing something simple? Much appreciated!


Solution

  • You can:

    select expand(both('friends').include('username', 'country')) 
    from #12:0
    

    Note that you should:

    select from #12:0
    

    instead of:

    select from Users where @rid = #12:0