UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Typed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Label Functions
    • Record Functions
    • Table Functions
  • Operators
  • Predicates
    • CASE
    • NULLIF
    • COALESCE
    • LET Value Expression
    • Value Query Expression
    • Index
    • Full-text Index
    • Vector Index
    • Spatial Index
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
  • Transaction
  • Trigger
  • Stored Procedure
    • Process
    • Session
    • Job
    • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • Access Control
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Expressions

LET Value Expression

The LET value expression allows you to define variables and use them immediately in an expression. It can be used for improving readability and simplifying more complex expressions.

Syntax
<let value expression> ::=
 "LET" <let variable definition list> "IN" <value expression> "END"

<let variable definition list> ::=
  <let variable definition> [ { "," <let variable definition> }... ]

<let variable definition> ::= <binding variable> "=" <value expression>

Example Graph

The following examples run against this graph:

To create this graph, run the following query against an empty graph:

GQL
INSERT (p1:Paper {_id:'P1', title:'Efficient Graph Search', score:6}),
       (p2:Paper {_id:'P2', title:'Optimizing Queries', score:9}),
       (p3:Paper {_id:'P3', title:'Path Patterns', score:7}),
       (p1)-[:Cites]->(p2),
       (p2)-[:Cites]->(p3)

Examples

GQL
RETURN LET x = 2, y = 1 IN x^2+y END AS result

Result:

result
5
GQL
MATCH (n:Paper)
RETURN n.title, LET plus = 1 IN n.score + plus END AS newScore

Result:

n.titlenewScore
Optimizing Queries10
Efficient Graph Search7
Path Patterns8