Solution for error 21S01 Column count doesn’t match value count at row 1

Once it was necessary to make a record in the table very quickly and I quickly wrote a SQL query, but after executing it I got an error:

(21S01) Column count doesn’t match value count at row 1

As it turned out, the error arose because I missed one value in the SQL query, that is, the number of columns in the table did not match the number of columns in my SQL query.

Let’s say I had an incorrect SQL query (for example, I specifically gave a simple SQL query and did not specify a value for the last “groups” column):

INSERT INTO table1 (id, key, methods, groups) VALUES ('', 'ixnfo.com', 4);

Then I looked at the table structure to check the columns:

SHOW CREATE TABLE table1;
DESC table1;

And I corrected my SQL query by specifying the value for the groups column – XXX, after that the SQL was successfully executed:

INSERT INTO table1 (id, key, methods, groups) VALUES ('', 'ixnfo.com', 4, 'XXX');

SELECT * FROM extreceipts_kkt;

See my other articles about MySQL

Leave a comment

Leave a Reply