Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional match does not support where clauses #2515

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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