cancel
Showing results for 
Search instead for 
Did you mean: 

Probably a simple MATCH statement

jeg
Node

Learning CYPHER, so this is probably a beginner level question...

My Person node can have an arc to an A node, which has a name. It can also have an arc to a B node, which likewise has a name. How do I find Persons who have at least one A arc and at least one B arc, so I can get the names from the A and B nodes?

2 REPLIES 2

Cobra
Ninja
Ninja

Hello @jeg and welcome to the Neo4j community

This is a template, you can add labels to node, and relations type between node if they are useful 🙂
The query return the name of the Person and a list of names for a and b.

MATCH (a)--(p:Person)--(b)
RETURN p.name AS p_name, collect(a.name) AS a_names, collect(b.name) AS b_names

Regards,
Cobra

Thank you very much! That did indeed get me going, and I was able to whittle it down to the exact query.