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.

(friend) in relationship in training data. What does that represent

Hello

I am working through the training dataset at https://guides.neo4j.com/sandbox/pole/index.html
I came across a query that I am not sure what it does and it isn't really explained. What does (friend) do on the first line of this query?

MATCH (p:Person)-[:KNOWS]-(friend)-[:PARTY_TO]->(:Crime)
WHERE NOT (p:Person)-[:PARTY_TO]->(:Crime)
RETURN p.name AS name, p.surname AS surname, p.nhs_no AS id, count(distinct friend) AS dangerousFriends
ORDER BY dangerousFriends DESC
LIMIT 5
2 REPLIES 2

I think figured it out. (friend) just appears to be an alias to whatever node the relationship between the person and knows points to.

Basically it is a dynamic variable name which you have given in the pattern to the node which are joined with a node have Label as Person with relationship as KNOWS and also the node is joined with Node having Label Crime relationship PARTY_TO