top of page
Волнистый абстрактный фон


Database: MySQL



VALUES row_constructor_list [ORDER BY column_designator] [LIMIT BY number]

ROW(value_list)[, ROW(value_list)][, ...]

value[, value][, ...]


The VALUES statement consists of the VALUES keyword followed by a list
of one or more row constructors, separated by commas. A row constructor
consists of the ROW() row constructor clause with a value list of one
or more scalar values enclosed in the parentheses. A value can be a
literal of any MySQL data type or an expression that resolves to a
scalar value.

ROW() cannot be empty (but each of the supplied scalar values can be
NULL). Each ROW() in the same VALUES statement must have the same
number of values in its value list.

The DEFAULT keyword is not supported by VALUES and causes a syntax
error, except when it is used to supply values in an INSERT statement.

The output of VALUES is a table:

mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8);
| column_0 | column_1 | column_2 |
| 1 | -2 | 3 |
| 5 | 7 | 9 |
| 4 | 6 | 8 |
3 rows in set (0.00 sec)

The columns of the table output from VALUES have the implicitly named
columns column_0, column_1, column_2, and so on, always beginning with
0. This fact can be used to order the rows by column using an optional
ORDER BY clause in the same way that this clause works with a SELECT
statement, as shown here:

mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8) ORDER BY column_1;
| column_0 | column_1 | column_2 |
| 1 | -2 | 3 |
| 4 | 6 | 8 |
| 5 | 7 | 9 |
3 rows in set (0.00 sec)

The VALUES statement also supports a LIMIT clause for limiting the
number of rows in the output.

URL: https://dev.mysql.com/doc/refman/8.0/en/values.html


bottom of page