Menu

MySQL Error 1136: Column Count Doesn't Match Value Count

Fix MySQL Error 1136 (21S01) by matching each INSERT column list with its VALUES or SELECT columns and checking defaults.

Posted on By
On this page

MySQL Error 1136 (SQLSTATE 21S01) means an INSERT statement supplies a different number of values than the number of target columns. The error text includes the row where MySQL detected the mismatch. See the MySQL 8.4 error reference.

Match an INSERT column list with its values

This statement names two columns but supplies only one value, so it raises Error 1136:

INSERT INTO contacts (name, email)
VALUES ('Ava');

Supply one value for each listed column:

INSERT INTO contacts (name, email)
VALUES ('Ava', 'ava@example.com');

If you omit the column list, MySQL expects values for every table column in table order. Check the schema with SHOW CREATE TABLE contacts; and prefer explicit column names so schema changes do not silently shift value positions. For the full syntax, see MySQL INSERT.

Leave optional columns out correctly

To omit a column, name only the columns you are inserting. In strict SQL mode (the MySQL default), an omitted column must be generated, nullable, or have a default value:

CREATE TABLE orders (
  order_id INT AUTO_INCREMENT PRIMARY KEY,
  customer_id INT NOT NULL,
  status VARCHAR(20) NOT NULL DEFAULT 'pending'
);

INSERT INTO orders (customer_id)
VALUES (42);

Here order_id is generated and status uses its default. If the column is in the insert list, provide a value or use DEFAULT:

INSERT INTO orders (customer_id, status)
VALUES (43, DEFAULT);

An omitted required column without a default is a different problem: in strict mode it can produce MySQL Error 1364. Adding an arbitrary value just to silence Error 1136 may store incorrect data. Non-strict SQL modes can supply implicit defaults, but relying on those defaults can hide missing data.

Check INSERT ... SELECT column counts

The target column list and the SELECT list must contain the same number of expressions:

INSERT INTO archived_orders (order_id, customer_id, created_at)
SELECT order_id, customer_id, created_at
FROM orders;

If the target has three columns but the SELECT returns two expressions, adjust the SELECT list or omit a target column that can safely use its default. See MySQL INSERT … SELECT.

When the error says row 2 or a later row

Every tuple in a multi-row VALUES clause must have the same number of values as the target column list. If the message names row 2 or higher, compare the tuples one by one. See MySQL Error 1136 at row 2 for a focused example.

INSERT IGNORE does not make a mismatched column/value structure correct. Fix the statement shape first; use INSERT IGNORE only when skipping certain data errors is the intended behavior. For more examples of multi-row inserts, see MySQL INSERT Multiple Rows.