Variable value expression¶
The variable value expression references the field of the record or the fields of the records in the current working dataset.
Syntax¶
- variable_value_expression
variable_value_expression ::=
variable
Parameters¶
variable¶
A variable that references a field by its name. The name can be a regular identifier or a delimited identifier enclosed with backticks (`). For more information about identifiers, see Rules for naming identifiers.
Examples¶
The following examples are based on the example dataset.
Define and return fields using variables¶
'''
LET
col1 = 3,
col2 = LIST[1,2,3,4,5],
col3 = "variable definition"
RETURN
col1 AS var1,
col2 AS var2,
col3 AS var3
'''
The preceding statement uses variables col1, col2, and col3 to define and return specific fields.
Return:
+------+-------------+---------------------+
| var1 | var2 | var3 |
+------+-------------+---------------------+
| 3 | [1,2,3,4,5] | variable definition |
+------+-------------+---------------------+
Use variables to return fields¶
USE movie MATCH (a@`User`)-[e:Watch]->(b) RETURN a, b LIMIT 3
The preceding statement uses variables a and b to specify the fields to be returned from the current working dataset after the MATCH operation is executed.
Return:
+------------------------------------------+-------------------------------------------------------------------------------+
| a | b |
+------------------------------------------+-------------------------------------------------------------------------------+
| (288977421288341505@User:Person{id:605}) | (289244237541670913@Movie:Movie{id:129,name:"Sen To Chihiro No Kamikakushi"}) |
| (288969428354203649@User:Person{id:370}) | (289244237541670913@Movie:Movie{id:129,name:"Sen To Chihiro No Kamikakushi"}) |
| (288962762564960258@User:Person{id:129}) | (289244237541670913@Movie:Movie{id:129,name:"Sen To Chihiro No Kamikakushi"}) |
+------------------------------------------+-------------------------------------------------------------------------------+