Reputation: 13
I was making some requests on Neo4j, and I've a little trouble at making one in particular.
These are the nodes and relationships I have on my database
Two of the elements:
I want to return the persons who are driving ("conduire") the same "Voiture" as Alice. This is what I wrote:
MATCH ((a:Personne)-[p:Conduire]->(b:Vehicule))
WHERE b.`Type`='Voiture' AND id(b) in [MATCH ((a:Personne)-[p:Conduire]->(b:Vehicule))
WHERE a.Nom='Alice'
RETURN id(b)]
RETURN a.Nom
Upvotes: 1
Views: 225
Reputation: 12684
Here is the query to return the persons who are driving the same car as Alice. Note that this will not return Alice because the match on b will not repeat the match made on a.
MATCH (a:Personne)-[:Conduire]->(:Vehicule)<-[:Conduire]-(b:Personne)
WHERE a.Nom='Alice'
RETURN b.Nom
Upvotes: 1