Fix Error 1136: Column count doesn't match value count at row 1?


You may get tis value, if you are missing the value for auto_increment column. The error is as follows −

mysql> insert into DemoTable1353 values('Chris',23);
ERROR 1136 (21S01): Column count doesn't match value count at row 1

You need to provide the value for auto_increment or leave it to automatic generation.

Let us see an example and create a table −

mysql> create table DemoTable1353
    -> (
    -> Id int NOT NULL AUTO_INCREMENT,
    -> Name varchar(20),
    -> Age int,
    -> PRIMARY KEY(Id)
    -> );
Query OK, 0 rows affected (0.52 sec)

Insert some records in the table using insert command. We haven’t inserted auto increment value and it will generate on its own −

mysql> insert into DemoTable1353(Name,Age) values('Chris',23);
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable1353(Name,Age) values('David',21);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1353(Name,Age) values('Bob',24);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1353(Name,Age) values('John',47);
Query OK, 1 row affected (0.11 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1353;

This will produce the following output −

+----+-------+------+
| Id | Name  | Age  |
+----+-------+------+
|  1 | Chris |   23 |
|  2 | David |   21 |
|  3 | Bob   |   24 |
|  4 | John  |   47 |
+----+-------+------+
4 rows in set (0.00 sec)

Updated on: 05-Nov-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements