Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Cypher

You're reading from   Learning Cypher Write powerful and efficient queries for Neo4j with Cypher, its official query language

Arrow left icon
Product type Paperback
Published in May 2014
Publisher
ISBN-13 9781783287758
Length 162 pages
Edition Edition
Arrow right icon
Author (1):
Arrow left icon
Onofrio Panzarino Onofrio Panzarino
Author Profile Icon Onofrio Panzarino
Onofrio Panzarino
Arrow right icon
View More author details
Toc

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 phase is important because the write phase will be executed for every item found in the read phase. For example, consider the following query:

MATCH (a:User {surname: "Roe"})
SET a.place = "London"
RETURN a

In this query, the SET command will be executed...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime