Skip to content

Commit

Permalink
Optional match does not support where clauses (#2515)
Browse files Browse the repository at this point in the history
* Optional match does not support where clauses

* Update 6.cheatsheet-for-ngql-command.md

* desc updates
  • Loading branch information
abby-cyber authored Jan 30, 2023
1 parent cc1dd9b commit d2252ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs-2.0/2.quick-start/6.cheatsheet-for-ngql-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@

| 模式 | 示例 | 说明 |
| ------------------- | ------------------------------------------------------------ | ---------------------------------------------- |
|作为MATCH语句的可选项去匹配图数据库中的模式 | `MATCH (m)-[]->(n) WHERE id(m)=="player100" OPTIONAL MATCH (n)-[]->(l) WHERE id(n)=="player125" RETURN id(m),id(n),id(l)` | 如果图数据库中没有对应的模式,对应的列返回NULL|
|作为`MATCH`语句的可选项去匹配图数据库中的模式 | `MATCH (m)-[]->(n) WHERE id(m)=="player100" OPTIONAL MATCH (n)-[]->(l) RETURN id(m),id(n),id(l)` | 如果图数据库中没有对应的模式,对应的列返回`NULL`|

* [LOOKUP](../3.ngql-guide/7.general-query-statements/5.lookup.md)

Expand Down
19 changes: 16 additions & 3 deletions docs-2.0/3.ngql-guide/7.general-query-statements/optional-match.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,27 @@

本文操作仅适用于 nGQL 中的 openCypher 方式。

## 使用限制

`OPTIONAL MATCH`子句中暂不支持使用`WHERE`子句。

## 示例

`MATCH`语句中使用`OPTIONAL MATCH`的示例如下:

```ngql
nebula> MATCH (m)-[]->(n) WHERE id(m)=="player100" \
OPTIONAL MATCH (n)-[]->(l) WHERE id(n)=="player125" \
OPTIONAL MATCH (n)-[]->(l) \
RETURN id(m),id(n),id(l);
+-------------+-------------+-------------+
| id(m) | id(n) | id(l) |
+-------------+-------------+-------------+
| "player100" | "team204" | __NULL__ |
| "player100" | "player101" | __NULL__ |
| "player100" | "player101" | "team204" |
| "player100" | "player101" | "team215" |
| "player100" | "player101" | "player100" |
| "player100" | "player101" | "player102" |
| "player100" | "player101" | "player125" |
| "player100" | "player125" | "team204" |
| "player100" | "player125" | "player100" |
+-------------+-------------+-------------+
Expand All @@ -32,11 +40,16 @@ nebula> MATCH (m)-[]->(n) WHERE id(m)=="player100" \

```ngql
nebula> MATCH (m)-[]->(n) WHERE id(m)=="player100" \
MATCH (n)-[]->(l) WHERE id(n)=="player125" \
MATCH (n)-[]->(l) \
RETURN id(m),id(n),id(l);
+-------------+-------------+-------------+
| id(m) | id(n) | id(l) |
+-------------+-------------+-------------+
| "player100" | "player101" | "team204" |
| "player100" | "player101" | "team215" |
| "player100" | "player101" | "player100" |
| "player100" | "player101" | "player102" |
| "player100" | "player101" | "player125" |
| "player100" | "player125" | "team204" |
| "player100" | "player125" | "player100" |
+-------------+-------------+-------------+
Expand Down

0 comments on commit d2252ab

Please sign in to comment.