我正在尝试构建一个密码查询,用于选择居住在城市和这些城市所属国家/地区的人。
这就是我对他们的看法:
MATCH (p:Person)-[r:LiveIn]-(city:City)
WHERE s.name= "a" OR s.name= "b" OR ...
MATCH (city)-[:IsIn]-(country:Country)
RETURN city,country,person
但我真正想说的是:
"select cities that have atleast 5 of those people (p) liveIn them"
我不太确定如何解决这个问题。
有什么建议吗?
答案 0 :(得分:3)
试试这个:
MATCH (p:Person)-[r:LiveIn]->(city:City)-[:IsIn]->(country:Country)
WHERE s.name in ["a", "b",...]
WITH city, country, count(p) as c, collect(p) as persons
WHERE c>=5
RETURN city,country,persons