I have been playing around with OrientDB sql queries to get a result set that contains not only vertices but also the internal edges that exists between them.
The query could be expressed as:
project
(without project itself) and all the edges between the vertices that are included in the resultsHere is how I have achieved it but I think it is not the proper way to do it.
select expand($union) let $vertices = ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ), $edges = ( select from ( select from E where @rid in ( select bothE() from ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) ) ) where out in ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) and in in ( select from ( traverse both() from (select from V where label = 'project') ) skip 1 ) ), $union = unionall($vertices, $edges)
And the expected results:
Problems with this solution:
select from V where label = 'project'
is also executed several times.Is there a better way to solve this use case?
Thanks.
Try this query:
select expand($c)
let $a=(traverse both(),bothE() from (select from V where label="project")),
$b=(traverse bothE() from (select from V where label="project")),
$c=difference($a,$b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With