Skip to main content

VALUES

Declaration

VALUES(col_name)

Description

The VALUES() function is only applicable to INSERT ... ON DUPLICATE KEY UPDATE statements. In other contexts, it returns NULL.

For INSERT ... ON DUPLICATE KEY UPDATE statements, the UPDATE clause can use the VALUES(col_name) function to reference column values from the INSERT statement.

Examples

INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6) ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
Query OK, 2 rows affected
Records: 2 Duplicates: 0 Warnings: 0