# Match and create relationship with each node in result

**URL:** <https://community.neo4j.com/t/match-and-create-relationship-with-each-node-in-result/44015>\
**Category:** Cypher\
**Created:** [September 6, 2021, 11:25am UTC](https://community.neo4j.com/t/match-and-create-relationship-with-each-node-in-result/44015 "2021-09-06T11:25:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skandagn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/skandagn/32/7692_2.png) [@skandagn](https://community.neo4j.com/u/skandagn)\
**Post date:** [September 6, 2021, 11:25am UTC](https://community.neo4j.com/t/match-and-create-relationship-with-each-node-in-result/44015/1 "2021-09-06T11:25:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bennu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bennu/32/11659_2.png) [@Bennu](https://community.neo4j.com/u/Bennu)\
**Post date:** [September 6, 2021, 11:52am UTC](https://community.neo4j.com/t/match-and-create-relationship-with-each-node-in-result/44015/2 "2021-09-06T11:52:30Z")

</div>

Hi,

You can try

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

```

Bennu

---

<div class="post-metadata">

**Author:** ![skandagn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/skandagn/32/7692_2.png) [@skandagn](https://community.neo4j.com/u/skandagn)\
**Post date:** [September 6, 2021, 11:54am UTC](https://community.neo4j.com/t/match-and-create-relationship-with-each-node-in-result/44015/3 "2021-09-06T11:54:40Z")

</div>

Thanks Bennu, Just now myself found the same!
