Hi guys.
Can anyone share with me a CREATE statement that has a match block inside to pull information and push into the properties set via the CREATE.
G
Hi guys.
Can anyone share with me a CREATE statement that has a match block inside to pull information and push into the properties set via the CREATE.
G
You can do it in a couple of ways:
First capture all the variables before the merge
MATCH (A:Node {property:'value'} )
WITH A.propertyToUse AS aProperty
MERGE (B:Another) SET B.target = aProperty
If you have complex statements, and are using variables, you can use apoc.cypher.run()
CALL apoc.cypher.run('MATCH (node {uuid: theVariable} ) RETURN someNode', { theVariable: 'some value' })
YIELD value
MERGE ...
(If memory doesnβt fail me - I understand later versions will allow for MATCH inside MERGE)
hi there.
thanks
guessing for belowβ¦
MATCH (A:Node {property:'value'} )
WITH A.propertyToUse AS aProperty
MERGE (B:Another) SET B.target = aProperty
I would probably want to ask/do a match with B, assume thats what weβre doing via the (A:Node {property:'value'} ) i.e.
MATCH (A:Node {property:'value'} )
WITH A.propertyToUse AS aProperty
MATCH (B:Another {property:'value'} )
MERGE (B:Another) SET B.target = aProperty
?
MATCH (A:Node {property:'value1'} )
WITH A.propertyToUse AS aProperty
MERGE (B:Another {property:'value2'} )
ON CREATE
... not sure if you would do anything?
ON MATCH
SET B.target = aProperty
Hi Josh
Thanks, give me some good options.
G
MATCH (A:Node {property:'value1'} )
WITH A.propertyToUse AS aProperty
MERGE (B:Another {property:'value2'} )
ON CREATE
... not sure if you would do anything?
ON MATCH
SET B.target = aProperty