id()
returns the id of a relationship or node.
Syntax: id(expression)
Returns: An Integer.
Arguments
Name | Description |
expression | An expression that returns a node or a relationship. |
Example
MATCH (a:Person {name:"Aayushii"})
RETURN id(a)
The value returned will be the id(s) of the node(s) which have the label “Person” and whose name property has the value “Aayushii”. For example, 7.
Example
MATCH (:Person)-[a:KNOWS]->(:Skill {name:"Java"})
RETURN id(a)
The value returned will be the id(s) of the relationship(s) which have the type “KNOWS”, and whose start node has the label Person, and the end node has the label Skill whose name property has the value “Java”. For example, 19.
Considerations
id(null)
returnsnull
.
Example
MATCH (a:Person)-[:STUDIES_AT]->(:College {name:"IIT Delhi"})
RETURN id(a)
Returns the following Result
id(a) |
23 27 32 |
Example
MATCH (a:Person)-[:STUDIES_AT]->(:College {name:"IIT Delhi"})
WHERE a.name="Sundar"
RETURN id(a)
Returns the following Result
id(a) |
27 |
Example
MATCH (:Person)-[b:STUDIES_AT]->(:College {name:"IIT Delhi"})
RETURN id(b)
Returns the following Result
id(b) |
22 28 34 |
Example
MATCH (a:Person)-[b:STUDIES_AT]->(:College {name:"IIT Delhi"})
WHERE a.name="Sundar"
RETURN id(b)
Returns the following Result
id(b) |
28 |
Example
MATCH id(null)
Returns the following Result
id(null) |
null |