如何通过在 Neo4j 中使用 cypher 声明变量并将它们传递到语句中来编写语句
How to write a statement by declaring variables and passing them into the statement using cypher in Neo4j
我正在尝试在 "Cypher" 中编写 "Neo4j" 语句来创建节点。我只想声明一些变量,为它们赋值并将它们传递到语句中,而不是直接在语句中赋值。我在下面列出了工作声明和我想要的声明格式。任何帮助将不胜感激。
我的工作陈述:
CREATE (n:Customers {Name:"Bharath" , GoestoRetailer: "Prestige
Store"})
WITH n
MATCH(c:Customers)
WITH c
MATCH (r:Retailer) WHERE r.StartTime = "9:00 AM" and r.Name
contains c.GoestoRetailer
CREATE (r)-[:NineDelivery]->(c)
要求的语句格式:
// Declaration of variables
WITH cName = "Bharath" as cName
WITH rName = "Prestige Store" as rName
WITH openingTime = "9:00 AM" as openingTime
CREATE (n:Customers {Name: cName, GoestoRetailer: rName})
WITH n.CustomerName = cName
WITH n
MATCH(c:Customers)
WITH c
//Condition
MATCH (r:Retailer) WHERE r.StartTime = openingTime and r.Name
contains c.GoestoRetailer
//Action
CREATE (r)-[:NineDelivery]->(c)
我想你可以像这样简单地使用 WITH:
WITH "Bharath" as cName, "Prestige Store" as rName, "9:00 AM" as openingTime
CREATE (n:Customers {Name: cName, GoestoRetailer: rName})
(...)
我正在尝试在 "Cypher" 中编写 "Neo4j" 语句来创建节点。我只想声明一些变量,为它们赋值并将它们传递到语句中,而不是直接在语句中赋值。我在下面列出了工作声明和我想要的声明格式。任何帮助将不胜感激。
我的工作陈述:
CREATE (n:Customers {Name:"Bharath" , GoestoRetailer: "Prestige
Store"})
WITH n
MATCH(c:Customers)
WITH c
MATCH (r:Retailer) WHERE r.StartTime = "9:00 AM" and r.Name
contains c.GoestoRetailer
CREATE (r)-[:NineDelivery]->(c)
要求的语句格式:
// Declaration of variables
WITH cName = "Bharath" as cName
WITH rName = "Prestige Store" as rName
WITH openingTime = "9:00 AM" as openingTime
CREATE (n:Customers {Name: cName, GoestoRetailer: rName})
WITH n.CustomerName = cName
WITH n
MATCH(c:Customers)
WITH c
//Condition
MATCH (r:Retailer) WHERE r.StartTime = openingTime and r.Name
contains c.GoestoRetailer
//Action
CREATE (r)-[:NineDelivery]->(c)
我想你可以像这样简单地使用 WITH:
WITH "Bharath" as cName, "Prestige Store" as rName, "9:00 AM" as openingTime
CREATE (n:Customers {Name: cName, GoestoRetailer: rName})
(...)