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.

How to mach nodes intersections?

Hi there,
If I have a set of nodes that have a unique constraint on the node name and I want to match more than one node by different names and got all the nodes that have relationships to these nodes together. How can I do it?

Example:

Node (Name):
James
Jack
David

Node (Food):
Pizza
Pasta
Sushi

And I have different relationships based on what food everyone like. How can I match the mutual food that only both David and James like?

Thanks

1 REPLY 1

ameyasoft
Graph Maven

Try something like this:

MATCH (p:Person)-[:LIKES]->(f:Food)
Where p.name = "David"

WITH p, f

MATCH (p1:Person)-[:LIKES]->(f) Where p1.name = "James"

RETURN p.name, p1.name, f.name;

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online