Reputation: 3
I am new to Neo4J and working on a project. I just wrote the following Cypher query to create a node as long as its more than a specific distance from another node. Here is the Cypher query:
MATCH(p:Point)
WITH p, p.Lat AS Lat1, p.Lng as Lng1, 53.3809441 as Lat2, -1.4901356 as Lng2
WITH p, Lat1, Lng1, Lat2, Lng2, (degrees(acos((sin(radians(Lat1))*sin(radians(Lat2)))+ (cos(radians(Lat1))*cos(radians(Lat2))*cos(radians(Lng1 - Lng2))))) * 60 * 1.1515 * 1.60934 * 1000) AS DM
WHERE DM > 558
WITH COUNT(p) AS c,
FOREACH(item IN CASE WHEN c = 0 THEN [1] ELSE [] END | CREATE (n:Point {Lat: 53.3809441, Lng: -1.4901356}))
I get a syntax error on the last lines that points at the pipe symbol "|". I am confused because everything seems right to me. Can anyone advise me what I am doing wrong please?
The specific error message is:
Upvotes: 0
Views: 440
Reputation: 41706
Remove the comma after WITH COUNT(p) AS c,
. It was probably an oversight.
FOREACH is a clause not an expression.
Upvotes: 2