Reputation: 13693
I have created a vehicle make called Toyota
and also created a new node store my vehicle models.
CREATE (Make:make{name: "Toyota"})
CREATE (Model:model {name: "Camry"})
CREATE (Make)-[r:MODEL_OF]->(Model)
RETURN Make, Model
I added two more vehicle models
CREATE (Model:model {name: "Vitz"})
CREATE (Model:model {name: "Corolla"})
and linked the two models to Toyota
MATCH (a:make), (b:model) WHERE a.name = "Toyota" AND b.name = "Vitz"
CREATE (a)-[r: MODEL_OF]->(b)
RETURN a,b
MATCH (a:make), (b:model) WHERE a.name = "Toyota" AND b.name = "Corolla"
CREATE (a)-[r: MODEL_OF]->(b)
RETURN a,b
How can i return all models of make Toyota
that have the relationship MODEL_OF
?
I have tried this
MATCH (Make:make {name: "Toyota"})<-[r:MODEL_OF]-(n)
RETURN n.name
and i get
(no changes, no records)
I have several models of Toyota
related to Toyota
so its not supposed to return zero results.
Upvotes: 0
Views: 30
Reputation: 5385
It seems your data and your query are using opposite directions.
data:
(:make)-[:MODEL_OF]->(:model)
query
(:make)<-[:MODEL_OF]-(:model)
So it is no surprise the query returns nothing. One of the two has to be changed.
Upvotes: 1