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
Is there any way to correct this?
Add a couple of WITHs?
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.
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)