在OrientDB中的变量中进行子选择

在OrientDB中的变量中进行子选择,orientdb,Orientdb,我有以下OrientDB SQL查询: select expand($all) let $a = (select groups, inV().firstName from ( select expand(outE()) from (select from user where uuid = 'abc') )), $b = (select groups, outV().firstName from ( select expand(inE()) from (select from u

我有以下OrientDB SQL查询:

select expand($all) let
$a = (select groups, inV().firstName from (
    select expand(outE()) from (select from user where uuid = 'abc')
)),
$b = (select groups, outV().firstName from (
    select expand(inE()) from (select from user where uuid = 'abc')
)),
$all = unionall($a, $b)
查询试图完成什么并不重要。无论如何,它是以这种形式工作的。但是,正如您所注意到的,重复了
select from user,其中uuid='abc'
。如何将该部分提取到变量中并多次重用


我已经试过了:

select expand($all) let
$x = (select from user where uuid = 'abc'),
$a = (select groups, inV().firstName from (
    select expand(outE()) from $x
)),
$b = (select groups, outV().firstName from (
    select expand(inE()) from $x
)),
$all = unionall($a, $b)

但是,没有用。所有查询都已成功解析,但返回空结果。我做错了什么


提前感谢。

您显示的查询仅将多个查询“组合”为单个查询并给出结果

您声明的变量保存特定查询的结果,该结果可在SQL函数中使用,如
UNIONALL()
。您不能在其他查询中使用它

我在文档中并没有找到任何这种类型的内容。也许更新的版本会支持它

select expand($all) let
$x = (select from user where uuid = 'abc'),
$a = (select groups, inV().firstName from (
    select expand($x.outE())
)),
$b = (select groups, outV().firstName from (
    select expand($x.inE())
)),
$all = unionall($a, $b)
select expand($all) let
$x = first((select from user where uuid = 'abc')),
$a = (select groups, inV().firstName from (
    select expand($x.outE())
)),
$b = (select groups, outV().firstName from (
    select expand($x.inE())
)),
$all = unionall($a, $b)