With clause not working as expected

7 views
Skip to first unread message

Michael Dougherty

unread,
Apr 17, 2015, 7:51:31 PM4/17/15
to ne...@googlegroups.com
Im very confused with what's going wrong....here's my database

CREATE (queen:Gliese { name : 'Queen'}),(eva:Human { name : 'Eva'}),(lisha:Human { name : 'Lisha'}),(queen)<-[:ENEMY_OF]-(eva),(queen)<-[:FRIEND_OF]-(eva),(queen)<-[:FRIEND_OF]-(lisha),(queen)<-[:ENEMY_OF]-(lisha),(lisha)-[:KILLED]->(eva);

I wanted to return any friend of the queen who killed an enemy of the queen.

So I wrote the following query


MATCH (queen:Gliese{name:'Queen'})
WITH queen
MATCH (a)-[:FRIEND_OF]->(queen),(b)-[:ENEMY_OF]->(queen),(a)-[:KILLED]->(b)
RETURN a.name, count(*) as count;


Instead of getting lisha, 1, as expected, I get (No rows).


Strangely if I do 

MATCH (a)-[:FRIEND_OF]->(queen),(b)-[:ENEMY_OF]->(queen),(a)-[:KILLED]->(b)
RETURN a.name, count(*) as count;

alone, I get the expected result. In addition if I do 


MATCH (queen:Gliese{name:'Queen'})
WITH queen
MATCH (a)-[:FRIEND_OF]->(n),(b)-[:ENEMY_OF]->(n),(a)-[:KILLED]->(b)
RETURN a.name, count(*) as count;


I get Lisha, 1 and Eva, 1! I don't really understand these differences!

In older versions my code seems to work, unless there's some other problem I don't get.


What's going on here?

Michael Hunger

unread,
Apr 17, 2015, 7:56:07 PM4/17/15
to ne...@googlegroups.com
Hi Michael,

works for me with Neo4j 2.2


Which version are you using?

Cheers, Michael

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages