Skip to content

Commit

Permalink
example of scope and order of variable and set operator (#3024)
Browse files Browse the repository at this point in the history
* example of scope and order of variable and set operator

* Update docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md

---------

Co-authored-by: abby.huang <78209557+abby-cyber@users.noreply.github.com>
  • Loading branch information
wey-gu and abby-cyber authored Oct 8, 2023
1 parent 3e68f50 commit 1324474
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,18 @@ nebula> $var = GO FROM "player100" OVER follow YIELD dst(edge) AS id; \
| "Spurs" | "Manu Ginobili" |
+-----------+-----------------+
```

## 集合运算与变量语句的范围与运算顺序

当我们需要对集合运算的复合语句进行变量赋值时,需要注意用括号包裹语句的范围,比如下边的例子里`$var`赋值的来源是两个语句`INTERSECT`之后的输出。

```ngql
$var = ( \
GO FROM "player100" OVER follow \
YIELD dst(edge) AS id \
INTERSECT \
GO FROM "player100" OVER follow \
YIELD dst(edge) AS id \
); \
GO FROM $var.id OVER follow YIELD follow.degree AS degree
```

0 comments on commit 1324474

Please sign in to comment.