Match statement

MATCH (d:accnt)-[:relation]-(p:Person)-[:relation]-(ctas:accnt)
where d.ind='S' and d.accnt='44564'
return d,p,ctas

I am trying to run the above query and but i am not able to get any data from this query.
where as i know that the accnt 4456 is connected to a person with realtionship 'relation'
what i was expecting is the d and ctas results will be same. but i am not getting any data back.
can anyone help me to understand why this is happening.

Not knowing your data, it’s hard to tell what is right and what is wrong. As a note, neo4j will not traverse the same relationship in a single match statement, so you would need two relationships connection the account node to the person node if you expect ‘d’ to be the same as ‘ctsa’ for one of the results.

If you are not getting what you expect from a long query pattern, it may help to break it apart and use ‘optional match’ as well. Optional match will return ‘null’ for a value that does not match instead of stopping the query when a match is not found.

Try the following. With this query it would be possible for a result to have ‘d’ and ‘ctas’ be the same node with only one relationship between them, as the traversal from ‘d’ to ‘ctas’ is now over two match statements and you have not specified a direction in the patterns. You could filter that result out by adding a ‘where’ clause to exclude that scenario.

What are the results?

MATCH (d:accnt)
where d.ind='S' and d.accnt='44564'
OPTIONAL MATCH (d)-[:relation]-(p:Person)
OPTIONAL MATCH (p)-[:relation]-(ctas:accnt)
return d,p,ctas
MATCH (d:accnt)
where d.ind='S' and d.accnt='44564'
OPTIONAL MATCH (d)-[:relation]-(p:Person)
OPTIONAL MATCH (p)-[:relation]-(ctas:accnt)
WHERE d<>ctas
return d,p,ctas

If this is not helpful, provide some data and explain what you expected to receive as a result.