An expression in Cypher can be:
13
, 40000
, 3.14
.
"Hello"
, 'World'
.
true
, false
, TRUE
, FALSE
.
n
, x
, rel
, myFancyIdentifier
, `A name with weird stuff in it[]!`
.
n.prop
, x.prop
, rel.thisProperty
, myFancyIdentifier.`(weird property name)`
.
n.prop?
, rel.thisProperty!
.
{param}
, {0}
["a", "b"]
, [1,2,3]
, ["a", 2, n.property, {param}]
, [ ]
.
length(p)
, nodes(p)
.
avg(x.prop)
, count(*)
.
:REL_TYPE
, :`REL TYPE`
, :REL1|REL2
.
a-->()<--b
.
CASE
expression
String literals can contain these escape sequences.
Escape sequence | Character |
---|---|
| Tab |
| Backspace |
| Newline |
| Carriage return |
| Form feed |
| Single quote |
| Double quote |
| Backslash |
Cypher supports CASE expressions, which is a generic conditional expression, similar to if/else statements in other
languages. Two variants of CASE
exist - the simple form and the generic form.
The expression is calculated, and compared in order with the WHEN
clauses until a match is found. If no match is found
the expression in the ELSE
clause is used, or null, if no ELSE
case exists.
Syntax: +CASE+ in
+WHEN+ value +THEN+ result
[+WHEN+ ...]
[+ELSE+ default]
+END+
Arguments:
Query.
MATCH n RETURN CASE n.eyes WHEN 'blue' THEN 1 WHEN 'brown' THEN 2 ELSE 3 END AS result
A string.
The predicates are evaluated in order until a true value is found, and the result value is used.If no match is found the expression in the +ELSE + clause is used, or null, if no + ELSE + case exists.
Syntax: +CASE+
+WHEN+ predicate +THEN+ result
[+WHEN+ ...]
[+ELSE+ result]
+END+
Arguments:
Query.
MATCH n RETURN CASE WHEN n.eyes = 'blue' THEN 1 WHEN n.age < 40 THEN 2 ELSE 3 END AS result
A string.
Copyright © 2013 Neo Technology