简体   繁体   English

在CREATE和MATCH之间需要Neo4j Cypher WITH

[英]Neo4j Cypher WITH is required between CREATE and MATCH

I want to execute several queries at the same time on the browser console, here are my requests : 我想在浏览器控制台上同时执行多个查询,这是我的请求:

CREATE (newNode1:NEW_NODE)
CREATE (newNode2:NEW_NODE)
MATCH (n1:LABEL_1 {id: "node1"}) CREATE (newNode1)-[:LINKED_TO]->(n1)
MATCH (n2:LABEL_2 {id: "node2"}) CREATE (newNode2)-[:LINKED_TO]->(n2)

When I execute them one by one there is no problem, but when I execute them at the same time, I get the following error : WITH is required between CREATE and MATCH 当我逐个执行它们没有问题,但是当我同时执行它们时,我得到以下错误:在CREATE和MATCH之间需要WITH

Is there any way to correct this? 有没有办法纠正这个?

Add a couple of WITHs? 添加几个WITH?

CREATE (newNode1:NEW_NODE)
CREATE (newNode2:NEW_NODE)
WITH newNode1, newNode2
MATCH (n1:LABEL_1 {id: "node1"}) 
CREATE (newNode1)-[:LINKED_TO]->(n1)
WITH newNode1, newNode2
MATCH (n2:LABEL_2 {id: "node2"}) 
CREATE (newNode2)-[:LINKED_TO]->(n2)

Alternatively, you could do it in a different order and avoid the WITHs, the difference being that it won't create anything if n1/n2 don't MATCH. 或者,您可以以不同的顺序执行此操作并避免使用WITHs,不同之处在于,如果n1 / n2不匹配,则不会创建任何内容。

MATCH (n1:LABEL_1 { id: "node1" }) 
MATCH (n2:LABEL_2 { id: "node2" }) 
CREATE (newNode1:NEW_NODE)-[:LINKED_TO]->(n1) 
CREATE (newNode2:NEW_NODE)-[:LINKED_TO]->(n2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM