У меня есть следующий SQL-запрос OrientDB:
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)
но, безрезультатно. Все запросы анализируются успешно, но возвращают пустой результат. Что я делаю не так?
Заранее спасибо.