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.

Probably a simple MATCH statement

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

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.