Syntax
Cypher Cheat Sheet - Neo4j Documentation Cheat Sheet
[USE]
[MATCH [WHERE]]
[OPTIONAL MATCH [WHERE]]
[WITH [ORDER BY] [SKIP] [LIMIT] [WHERE]]
RETURN [ORDER BY] [SKIP] [LIMIT]
MATCH
MATCH
is similar to SELECT
in SQL.
MATCH(n)
: match all nodeMATCH (n:Person)-[:KNOWS]->(m:Person)
: Match nodes and relationships involved in the relationshipMATCH (a:Person {name: 'Andy'})
: Similar toWHERE
, find node by propertyMATCH p1=(u1:User)-[:COMMENTED]->(c1:Comment)-[:COMMENTED_ON]-(q:Question)
: Relationship can be chained. User commented comment "c1" that is commented on question "q"
WHERE
Same as SQL WHERE
, acts as a filter.
WHERE n.property <> $value
WHERE r:R1|R2
: OR relationshipMATCH (a:Person)-[r:KNOWS WHERE r.since < minYear]->(b:Person)
: relationship used as predicate in aWHERE
clause.