
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Resolve the error Column count doesn’t match value count in MySQL?
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)
- Related Articles
- Fix Error 1136: Column count doesn't match value count at row 1?
- Count the same value of each row in a MySQL column?
- Count number of times value appears in particular column in MySQL?
- Resolve the MySQL error 'TYPE=MyISAM'?
- How to count the distinct column in MySQL?
- How to get the count of each distinct value in a column in MySQL?
- MySQL select count by value?
- How to get the count of a specific value in a column with MySQL?
- Resolve MySQL ERROR 1064 (42000): You have an error in your syntax?
- Linux – How to resolve the error "can't connect to Docker daemon"
- MySQL query to return the count of only NO values from corresponding column value
- Count the number of comma’s in every record from a comma-separated value column in MySQL
- MySQL system variable table_type doesn't work?
- Resolve Unknown database in JDBC error with Java-MySQL?\n
- Resolve Syntax error near “ORDER BY order DESC” in MySQL?

Advertisements