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.

New here. And I have a question relating to relationship

I am sorry if this was posted by others last time as I am just a few days ago old to this thing.

I have a question about the relationship... That is;

MATCH (town)-[:LOCATED_IN]-(blocks { food_establishment: true })
WITH town, count(*) as num_food_establishment, collect(blocks.id) as list_food_establishment
RETURN town.id, num_food_establishment

Since the above example is meant for the attributes only, I was wondering if there is a relationship equivalent of doing it.

My idea was to store the number of relationships per label as a property of the same label.

1 REPLY 1

Hi there! You can just name the variable for the relationship and useit like the nodes exampole you have there:

MATCH (town)-[rel:LOCATED_IN]-(blocks { food_establishment: true })

with rel...and then you use rel varible as you want. What's the aim in counting the relationships? if the relationship has properties, you can access them just like the node ones.