Skip to main content
Version: 1.1.0

LET

LET statement

The LET statement sets and stores a value which can then be used in a subsequent query. A parameter can store any value, including the result of a query.

Statement syntax

SurrealQL Syntax
LET $@parameter = @value;

Example usage

The following query shows example usage of this statement.

-- Define the parameter
LET $name = "tobie";
-- Use the parameter
CREATE person SET name = $name;

The following query shows the LET statement being used to store the result of a subquery.

-- Define the parameter
-- Define the parameter
LET $adults = (SELECT * FROM person WHERE age > 18);
-- Use the parameter
UPDATE $adults SET adult = true;