Loops

Due to the nature of the Cypher queries, usually, you won't need something like a loop used in other programming languages. In fact, as you have probably already realized, the general structure of a Cypher query is formed by three phases and each one of these is optional. The phases are as follows:

  • Read: This is the phase where you read data from the graph using the START, MATCH, or OPTIONAL MATCH clauses.
  • Write: This is the phase where you modify the graph using CREATE, MERGE, SET, and all the other clauses we learned in this chapter.
  • Return: This is the phase where you choose what to return to the caller by using the RETURN clause. This part can be replaced by a WITH clause and then the query can start again from the read phase.

The read ...

Get Learning Cypher now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.