Skip to content

Commit 6bfa06d

Browse files
committed
updated
1 parent a16a1f1 commit 6bfa06d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/en/sql-reference/00-sql-reference/41-sql-variables.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ The SHOW VARIABLES command has a corresponding table function, [SHOW_VARIABLES](
1919

2020
This section explains how to effectively use variables in your queries, leveraging both `$` for value substitution and `IDENTIFIER` for accessing database objects like tables.
2121

22-
### Accessing Variables with `$`
22+
### Accessing Variables with `$` and `getvariable()`
2323

24-
The `$` symbol is used to reference the value of a variable within a SQL statement. This allows for dynamic substitution, where the variable's value is directly embedded into the query at runtime.
24+
You can reference the value of a variable within a SQL statement using either the `$` symbol or the `getvariable()` function. Both methods allow dynamic substitution, where the variable's value is directly embedded into the query at runtime.
2525

2626
```sql title='Example:'
2727
-- Set a variable to use as a filter value
2828
SET VARIABLE threshold = 100;
2929

30-
-- Use the variable in a query
30+
-- Use the variable in a query with $
3131
SELECT * FROM sales WHERE amount > $threshold;
32+
33+
-- Alternatively, use the getvariable() function
34+
SELECT * FROM sales WHERE amount > getvariable('threshold');
3235
```
3336

3437
### Accessing Objects with `IDENTIFIER`

docs/en/sql-reference/10-sql-commands/00-ddl/15-variable/set-variable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ empid|amount|month|
4242
1| 2|3 |
4343
```
4444

45-
The following example sets multiple variables from a query:
45+
The following example sets multiple variables from a query in a single statement. The query must return exactly one row, with the same number of values as the variables being set.
4646

4747
```sql
4848
-- Sets variable a to 3 and b to 55

0 commit comments

Comments
 (0)