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

时间:2015-02-26 00:08:45

标签: 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 user where uuid = 'abc')
)),
$all = unionall($a, $b)

与查询尝试完成的内容无关。无论如何,它以这种形式工作。但是,正如您所注意到的,select from user where 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)

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)
但是,无济于事。所有查询都已成功解析,但返回空结果。我做错了什么?

提前致谢。

1 个答案:

答案 0 :(得分:0)

您仅显示的查询'结合了'多个查询到单个查询并给出结果。

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

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