O'Reilly logo

Learning Cypher by Onofrio Panzarino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Functions

Functions are grouped by usage. Except for the COALESCE function, all of these functions return a null value if any argument has a null value.

COALESCE

The COALESCE function takes any number of parameters (at least one) and returns the first non-null value. It returns a null value only in case all the parameters have null values.

Usually, this function is used every time you have to deal with null values and want a fallback value in case of a null value. Consider the following query:

MATCH (aa:Book) 
WHERE 'novel' IN COALESCE(aa.tags, ['novel']) 
RETURN aa.title

This query returns all books that have novel in their tags, but will return all the books that do not have no tags set as well. In fact, if a book doesn't have the tags property, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required