cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Match and create relationship with each node in result

skandagn
Node Link

Hi,

I want to do the following

Match n:Node WHERE n.someprop = somevalue
Match m:ANode WHERE ID(m)=21
Create relationship for all n nodes with m

How can I achieve it with a single cypher? Is FOREACH is an effective way to do it? Or someother way is there to do it.

Thanks,
Skanda

1 ACCEPTED SOLUTION

Bennu
Graph Fellow

Hi,

You can try

Match m:ANode WHERE ID(m)=21
with m
Match n:Node WHERE n.someprop = somevalue
CREATE (m)-[:REL]->(n)

Bennu

View solution in original post

2 REPLIES 2

Bennu
Graph Fellow

Hi,

You can try

Match m:ANode WHERE ID(m)=21
with m
Match n:Node WHERE n.someprop = somevalue
CREATE (m)-[:REL]->(n)

Bennu

skandagn
Node Link

Thanks Bennu, Just now myself found the same!