Fix “ERROR 3942 (HY000): Each row of a VALUES clause must have at least one column” when using the VALUES Statement in MySQL

If you’re getting an error that reads “ERROR 3942 (HY000): Each row of a VALUES clause must have at least one column” in MySQL, you could have an empty row constructor when using the VALUES statement.

To fix this issue, make sure you’ve got at least one value in each ROW() clause within the VALUES statement.

Example of the Error

Here’s an example of code that results in the error:

VALUES ROW();

Result:

ERROR 3942 (HY000): Each row of a VALUES clause must have at least one column, unless when used as source in an INSERT statement.

This is a very simple example, but its simplicity shows us exactly what went wrong. I’m using the VALUES statement, but with an empty ROW() clause.

Solution

To fix the issue, all we need to do is provide at least one value for the ROW() clause:

VALUES ROW('Jet');

Result:

+----------+
| column_0 |
+----------+
| Jet      |
+----------+

Usually, we would include more than one value in each ROW() clause, and perhaps more than one ROW() clause. For example:

VALUES ROW(1, 'Jet', 'Black'), ROW(2, 'Faye', 'Valentine');

Result:

+----------+----------+-----------+
| column_0 | column_1 | column_2  |
+----------+----------+-----------+
|        1 | Jet      | Black     |
|        2 | Faye     | Valentine |
+----------+----------+-----------+

Either way, we need to provide at least one value to each ROW() clause.