nirvanagar
nirvanagar

Reputation: 23

MySQL - Column count doesn't match value count at row 1 - Syntax Appears Correct

This is my first time posting here so please go easy on me! A few things I've noticed: First off, this query throws out the following error:

INSERT INTO test_table (col_one, col_two, col_three, col_four, col_five) VALUES (1, 2), ('three', 'four'), ('five', 'six'), (0, 0), ('seven', 'eight');

#1136 - Column count doesn't match value count at row 1

After changing the column names to names that were less descriptive and not in the table, I decided to run the query again just to see if it would work. It threw out the same error, rather than saying that 'col_one' doesn't exist in test_table. I've gone through all the other posts about this error, and in most cases people either miss commas or forget to specify the columns they're going to insert into. In my case, I can't see either of those two common errors. Anyone else have any thoughts? I've also read about stored procedures but I don't have any stored procedures on test_table that I know of. (Unless they can be added without my knowledge)

I appreciate any help, guys!

Upvotes: 0

Views: 824

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175556

In your query:

INSERT INTO test_table (col_one, col_two, col_three,  col_four,   col_five) 
VALUES (1, 2)                            -- missing   -- missing  -- missing
     , ('three', 'four')
     , ('five', 'six')
     , (0, 0)
     , ('seven', 'eight');

You try to insert values for 5 columns but you provide only 2 values per row. This is why you get error:

#1136 - Column count doesn't match value count at row 1

Upvotes: 0

Related Questions