1058
MySQLERRORCommonDMLHIGH confidence

Column count doesn't match value count at row N

Production Risk

Low — INSERT is rejected; no partial write occurs.

What this means

ER_WRONG_VALUE_COUNT_ON_ROW (1058, SQLSTATE 21S01) is raised when an INSERT statement provides a different number of values than there are columns (either in the table definition or the explicit column list).

Why it happens
  1. 1INSERT VALUES list has more or fewer items than the column list
  2. 2Column list was omitted and the table has a different number of columns than the VALUES clause
  3. 3Multi-row INSERT has a row with a different value count than the first row
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (a INT, b INT, c INT);
INSERT INTO t VALUES (1, 2); -- only 2 values for 3 columns

expected output

ERROR 1058 (21S01): Column count doesn't match value count at row 1

Fix

Match the number of values to the number of columns

WHEN Always — provide an explicit column list to make the mapping clear.

Match the number of values to the number of columns
INSERT INTO t (a, b) VALUES (1, 2);
-- or provide all values:
INSERT INTO t VALUES (1, 2, 3);

Why this works

Using an explicit column list is defensive — it makes INSERT statements resilient to future column additions.

What not to do

Omit the column list and rely on table column order

Column-order-dependent INSERTs break silently when columns are added or reordered.

Sources
Official documentation ↗

MySQL 8.0 — 1058 ER_WRONG_VALUE_COUNT_ON_ROW

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors