0

I need a bit of help with creating a certain Cyper query in Memgraph. I want to copy each node in the database and for each create 3 clones with specifing different properties (e.g. every one of them has different id property).

This is what I've come up with but it is not quite working as I imagined it:

MATCH (n)
UNWIND [1, 2, 3] AS i
CREATE (copy:Clone {id: i, name: n.name + ' Clone ' + i})
SET copy.property1 ...
RETURN copy
MPesi
  • 212
  • 8

1 Answers1

0

I think subqueries would make this a lot easier for you. Try running something like this query and see if the results are what you're looking for:

MATCH (p:Person)
CALL {
FOREACH (i IN range(1, 5) | CREATE(:Person {id: i}))
}
MATCH (n) RETURN COUNT(n);
An Martin
  • 53
  • 2