- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Resolve the error Column count doesn’t match value count in MySQL?
152 Lectures 16 hours
87 Lectures 5.5 hours
This type of error occurs when number of columns does not match whenever you are inserting records in the destination table. For a demo example, let us create a table
mysql> create table errorDemo -> ( -> User_Id int NOT NULL AUTO_INCREMENT, -> User_Name varchar(20), -> PRIMARY KEY(User_Id) -> ); Query OK, 0 rows affected (0.47 sec)
The error is as follows
mysql> insert into errorDemo values('John'); ERROR 1136 (21S01): Column count doesn't match value count at row 1
To avoid this type of error, you need to use the following syntax
insert into yourTableName(yourColumnName1,yourColumnName2,...N)values(yourValue1,yourValue2,....N);
Insert some records in the table using insert command.
The query is as follows
mysql> insert into errorDemo(User_Name) values('John'); Query OK, 1 row affected (0.12 sec) mysql> insert into errorDemo(User_Name) values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into errorDemo(User_Name) values('Sam'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from errorDemo;
The following is the output
+---------+-----------+ | User_Id | User_Name | +---------+-----------+ | 1 | John | | 2 | Carol | | 3 | Sam | +---------+-----------+ 3 rows in set (0.00 sec)
- Fix Error 1136: Column count doesn't match value count at row 1?
- Count the same value of each row in a MySQL column?
- Resolve the MySQL error 'TYPE=MyISAM'?
- MySQL select count by value?
- How to count the distinct column in MySQL?
- Count number of times value appears in particular column in MySQL?
- jQuery .val change doesn't change input value?
- MySQL system variable table_type doesn't work?
- How to get the count of each distinct value in a column in MySQL?
- Resolve MySQL ERROR 1064 (42000): You have an error in your syntax?
- Resolve Unknown database in JDBC error with Java-MySQL?
- How to get the count of a specific value in a column with MySQL?
- Adding a column that doesn't exist in a query?
- Count value for multiple columns in MySQL?
- Why doesn't MySQL support millisecond / microsecond precision?