This question is based on my earlier post on neo4j
I am trying to find out the names of the person living in city 'X'. I am using 2 nodes: Person and City for this purpose and a relationship exists [LIVES_IN]. I have created 4 nodes and 2 relationships as such:
CREATE (m:Person { name : 'sa', paswrd : 'abc' });
CREATE (n:Person { name : 'ti', paswrd : 'abc' });
CREATE (o:City { name : 'pune' });
CREATE (p:City { name : 'mumbai' });
CREATE (m)-[:LIVES_IN]->(o);
CREATE (n)-[:LIVES_IN]->(o);
Now, to get the persons who are living in 'pune' i try to write this query:
MATCH (x:City)<-[:LIVES_IN]-(y:Person) where x.name='pune' RETURN y.name;
But it returns:
==> +--------+
==> | y.name |
==> +--------+
==> +--------+
==> 0 row
==> 47 ms
Can you please advise me how to do it, then? For your kind information, I am presently using Neo4j2.0.1