VALUES()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Used in the UPDATE
clause of an INSERT... ON DUPLICATE KEY UPDATE
statement to refer to a column's inserted value.
USAGE
VALUES(column_name)
Argument Name | Description |
---|---|
| A column name in the |
DETAILS
VALUES()
is a helper function that returns a column's to-be-inserted value when called in the UPDATE
clause of an INSERT... ON DUPLICATE KEY UPDATE
statement.
Not to be confused with the VALUES
syntax in an INSERT
statement that is used to indicate that one or more rows of literal data follows.
EXAMPLES
CREATE TABLE t (
a INT PRIMARY KEY,
b INT,
c INT
);
Note that this is not the VALUES() function:
INSERT INTO t VALUES (1,2,3), (4,5,6);
This is the VALUES() function:
INSERT INTO t SET a = 1, b = 7, c = 8
ON DUPLICATE KEY UPDATE c = c + VALUES(c);
SELECT * FROM t;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 2 | 11 |
| 4 | 5 | 6 |
+---+------+------+