# Limit for multiple selection of nodes and relationships

**URL:** <https://community.neo4j.com/t/limit-for-multiple-selection-of-nodes-and-relationships/49361>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [December 22, 2021, 5:32am UTC](https://community.neo4j.com/t/limit-for-multiple-selection-of-nodes-and-relationships/49361 "2021-12-22T05:32:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinayak.bali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/vinayak.bali/32/3105_2.png) [@vinayak.bali](https://community.neo4j.com/u/vinayak.bali)\
**Post date:** [December 22, 2021, 5:32am UTC](https://community.neo4j.com/t/limit-for-multiple-selection-of-nodes-and-relationships/49361/1 "2021-12-22T05:32:16Z")

</div>

![Screenshot 2021-12-09 at 2.25.21 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/1/2/126fa29c7ad0610611a6d846650b8e7ebf63ea35.jpeg)

The data model is as shown in the above diagram.  
The queries are generated based on multiple selections of nodes and relationships. A sample query is as follows:

MATCH (Ve\_0:Node4)-[Su\_2:Rel1]-\>(Ma\_1:Node3) WHERE Ma\_1.property1 IN ['A','B','C']  
OPTIONAL MATCH (Ma\_1)-[St\_5:Rel2]-\>(Pl\_4:Node2)  
OPTIONAL MATCH (Pl\_4)-[Sh\_8:Rel3]-\>(Cu\_7:Node1)  
OPTIONAL MATCH (Ma\_1)-[De\_11:Rel4]-\>(Cu\_7)  
OPTIONAL MATCH (Ve\_0)-[Su\_14:Rel5]-\>(Pl\_4)  
RETURN Ve\_0,Ma\_1,Su\_2,Pl\_4,St\_5,Cu\_7,Sh\_8,De\_11,Su\_14  
LIMIT 100

Considering the above query, the limit is applied to the combination used in the return statement. 100 records of Ve\_0,Ma\_1,Su\_2,Pl\_4,St\_5,Cu\_7,Sh\_8,De\_11,Su\_14 are returned.

How to apply the limit on each entity/relation in the graph? (Ve\_0 10, Ma\_1 20, Su\_2 30 and so on)

Also, when limit 100 is used A is only returned along with other nodes and relationships, for limit 300 A and B both are returned, ideally A, B, C must be returned for any limit.

Request you to suggest some changes in the queries to achieve the same.

---

<div class="post-metadata">

**Author:** ![martin3](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin3/32/21016_2.png) [@martin3](https://community.neo4j.com/u/martin3)\
**Post date:** [December 27, 2021, 9:10pm UTC](https://community.neo4j.com/t/limit-for-multiple-selection-of-nodes-and-relationships/49361/2 "2021-12-27T21:10:22Z")

</div>

You could use RETURN and LIMIT multiple times if you use subqueries:

> **[CALL {} (subquery) - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/)**
>
> The \`+CALL {}+\` clause evaluates a subquery that returns some values.
