Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column count doesn't match value count at row 1

So I read the other posts but this question is unique. So this SQL dump file has this as the last entry.

INSERT INTO `wp_posts` VALUES(2781, 3, '2013-01-04 17:24:19', '2013-01-05 00:24:19'. 

I'm trying to insert this value to the table...

INSERT INTO `wp_posts` VALUES(5, 5, '2005-04-11 09:54:35', '2005-04-11 17:54:35' 

it gives me the error, "Column count doesn't match value count at row 1." So I'm lost on the concept of how the column and row apply here.

Doesn't 2781,3 mean row 2781 and column 3? And doesn't 5,5 mean row 5 and column 5?

like image 298
user2705462 Avatar asked Aug 21 '13 23:08

user2705462


People also ask

How to fix column count doesn t match value count at row 1?

To resolve this “Column count doesn't match value count at row 1” error, you have to ensure that the columns in the table or your INSERT statement match the values you are inserting. The best way to do this is to specify the columns you want in your INSERT statement and ensure the VALUES clause matches the column list.

How do I fix error 1136 in MySQL?

To fix this issue, make sure you're inserting the correct number of columns into the table. Alternatively, you can name the columns in your INSERT statement so that MySQL knows which columns your data needs to be inserted into.

How do you find the column count in a table?

mysql> SELECT COUNT(*) AS NUMBEROFCOLUMNS FROM INFORMATION_SCHEMA. COLUMNS -> WHERE table_schema = 'business' AND table_name = 'NumberOfColumns'; The output displays the number of columns.

How do I add a column to a table in MySQL?

Syntax. The syntax to add a column in a table in MySQL (using the ALTER TABLE statement) is: ALTER TABLE table_name ADD new_column_name column_definition [ FIRST | AFTER column_name ];


2 Answers

The error means that you are providing not as much data as the table wp_posts does contain columns. And now the DB engine does not know in which columns to put your data.

To overcome this you must provide the names of the columns you want to fill. Example:

insert into wp_posts (column_name1, column_name2) values (1, 3) 

Look up the table definition and see which columns you want to fill.

And insert means you are inserting a new record. You are not modifying an existing one. Use update for that.

like image 53
juergen d Avatar answered Oct 05 '22 01:10

juergen d


  1. you missed the comma between two values or column name
  2. you put extra values or an extra column name
like image 40
V Kash Singh Avatar answered Oct 05 '22 01:10

V Kash Singh