📅  最后修改于: 2020-11-25 00:47:08             🧑  作者: Mango
在Neo4j中,RETURN子句用于返回节点,关系和属性。通过使用RETURN子句,您将获得以下内容:
句法:
Create (node:label {properties})
RETURN node
例:
在继续该示例之前,首先创建一些节点和关系。
Create (p:player {name: "Mahendra Singh Dhoni", YOB: 1981, POB: "Ranchi"})
CREATE (c:Country {name: "India", result: "Winners"})
CREATE (CT2013:Tornament {name: "ICC Champions Trophy 2013"})
CREATE (c)-[r1:WINNERS_OF {NRR:0.938 ,pts:6}]->(CT2013)
CREATE(p)-[r2:CAPTAIN_OF]->(c)
这将创建3个节点和2个关系。
现在返回一个节点。
Create (p:player {name: "Mahendra Singh Dhoni", YOB: 1981, POB: "Ranchi"})
RETURN p
输出:
句法:
Create (node1:label {properties})
Create (node2:label {properties})
.
.
Create (node N:label {properties})
RETURN node1, node2.... node N
例:
让我们返回2个节点c和CT2013
CREATE (c:Country {name: "India", result: "Winners"})
CREATE (CT2013:Tornament {name: "ICC Champions Trophy 2013"})
RETURN c, CT2013
输出:
句法:
CREATE (node1)-[Relationship:Relationship_type]->(node2)
RETURN Relationship
例:
请参见此示例,该示例创建两个关系并返回它们。
CREATE (c)-[r1:WINNERS_OF {NRR:0.938 ,pts:6}]->(CT2013)
CREATE(p)-[r2:CAPTAIN_OF]->(c)
RETURN r1, r2
输出:
句法:
Match (node:label {properties . . . . . . . . . . })
Return node.property
例:
让我们返回节点p的属性。
Match (p:player {name: "Mahendra Singh Dhoni", YOB: 1981, POB: "Ranchi"})
Return p.name, p.POB
输出:
例:
Match m = (n {name: "India", result: "Winners"})-[r]-(x)
RETURN *
输出: