Neo4j 简明教程

Neo4j - With Clause

可以使用 WITH 子句将查询部分链接起来。

You can chain the query arts together using the WITH clause.

Syntax

以下是 WITH 子句的语法。

Following is the syntax of the WITH clause.

MATCH (n)
WITH n
ORDER BY n.property
RETURN collect(n.property)

Example

以下是一个示例 Cypher 查询,演示了 WITH 子句的用法。

Following is a sample Cypher Query which demonstrates the usage of the WITH clause.

MATCH (n)
WITH n
ORDER BY n.name DESC LIMIT 3
RETURN collect(n.name)

执行上述查询,执行以下步骤:

To execute the above query, carry out the following steps −

Step 1 - 打开 Neo4j Desktop App 并启动 Neo4j Server。使用 URL http://localhost:7474/ 打开 Neo4j 的内置浏览器应用,如下面的屏幕截图所示。

Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.

browser app

Step 2 - 在美元提示符中复制并粘贴所需的查询,并按播放按钮(执行查询)突出显示在下面的屏幕截图中。

Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.

return collect

Result

执行后,您将获得以下结果。

On executing, you will get the following result.

collect result