All pages
Powered by GitBook
1 of 3

Loading...

Loading...

Loading...

Assignment Operator (:=)

Syntax

var_name := expr

Description

Assignment operator for assigning a value. The value on the right is assigned to the variable on left.

Unlike the = operator, := can always be used to assign a value to a variable.

This operator works with both and .

When assigning the same value to several variables, can be useful.

Examples

See Also

This page is licensed: CC BY-SA / Gnu FDL

user-defined variables
local variables
LAST_VALUE()
Operator Precedence
SELECT @x := 10;
+----------+
| @x := 10 |
+----------+
|       10 |
+----------+

SELECT @x, @y := @x;
+------+----------+
| @x   | @y := @x |
+------+----------+
|   10 |       10 |
+------+----------+

Assignment Operators

Learn about assignment operators in MariaDB Server SQL. This section details how to assign values to variables and columns, essential for data manipulation and programmatic logic.

Assignment Operator (=)

Syntax

identifier = expr

Description

The equal sign is used as both an assignment operator in certain contexts, and as a comparison operator. When used as assignment operator, the value on the right is assigned to the variable (or column, in some contexts) on the left.

Since its use can be ambiguous, unlike the , the = assignment operator cannot be used in all contexts, and is only valid as part of a statement, or the SET clause of an statement

This operator works with both and .

Examples

See Also

This page is licensed: CC BY-SA / Gnu FDL

:= assignment operator
SET
UPDATE
user-defined variables
local variables
Operator Precedence
UPDATE table_name SET x = 2 WHERE x > 100;
SET @x = 1, @y := 2;