Collections:
VALUES() - Column Value for "ON DUPLICATE KEY UPDATE"
How to obtain the inserting value of given column in the "ON DUPLICATE KEY UPDATE" clause using the VALUES() function?
✍: FYIcenter.com
VALUES(col) is a MySQL built-in function that
returns the inserting value of a given column and use it
in the "ON DUPLICATE KEY UPDATE" clause.
For example:
CREATE TABLE MyTable (id INTEGER UNIQUE, count INTEGER); INSERT INTO MyTable VALUES (1, 1) ON DUPLICATE KEY UPDATE count = count+VALUES(count); INSERT INTO MyTable VALUES (1, 1) ON DUPLICATE KEY UPDATE count = count+VALUES(count); INSERT INTO MyTable VALUES (1, 1) ON DUPLICATE KEY UPDATE count = count+VALUES(count); INSERT INTO MyTable VALUES (1, 1) ON DUPLICATE KEY UPDATE count = count+VALUES(count); SELECT * FROM MyTable; -- +------+-------+ -- | id | count | -- +------+-------+ -- | 1 | 4 | -- +------+-------+
Reference information of the VALUES() function:
VALUES(col): val Returns the inserting value of the given column. Arguments, return value and availability: col: Required. The column name referred in the INSERT statement. val: Return value. The inserting value of the given column. Available since MySQL 4.0.
⇐ UPDATEXML() - Updating Child Element in XML
2025-10-24, 971🔥, 0💬
Popular Posts:
What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema in Oracle? For a us...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
How To Install PHP on Windows in MySQL? The best way to download and install PHP on Windows systems ...