asc*_*oni 5 sql graph-databases orientdb
我一直在使用OrientDB sql查询来获取一个结果集,该结果集不仅包含顶点,还包含它们之间存在的内部边.
查询可以表示为:
project(没有项目本身)以及结果中包含的顶点之间的所有边这是我如何实现它,但我认为这不是正确的方法.
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)
并且预期的结果是:
此解决方案的问题:
select from V where label = 'project'也会执行多次.有没有更好的方法来解决这个用例?
谢谢.
试试这个查询:
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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
524 次 |
| 最近记录: |