I am fairly new to Neo4J and have a problem in a Cypher query.
I write cypher queries through Neo4J java and my Neo4J database is designed as follows:
I have a user node with attributes such as id, name, age, email, gender and a node city. Every user is related to a city node(with attributes id, name) by a relationship (lives). However there can be a case when a user is not associated with city.
Now my scenario of the query is such that I want to fetch all details of user and the city he lives in, in a single query which is.
match p, c, p-[:lives]->c where p.type = 'com.Person' and c.type='com.City' and p.id = 12345 return p.name, p.age, p.email, p.gender, c.name;
The query works well when user is related to a city, but it fails in case when a user is not associated with a city.
Could you please help me with a query that can handle both the scenarios.