Arman H
Arman H

Reputation: 1754

Column count doesn't match value count in MySQL

Whenever I am trying to insert data in table:

INSERT INTO `operator`(`id`, `operator_name`, `email`, `info`)
VALUES (1,'Bangalink','This is all about Banglalink'),
(2, 'Robi', 'This is all about Robi');

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

How can i fix it? I don't understand what need to do. TIA

Upvotes: 0

Views: 60

Answers (2)

Sardor Dushamov
Sardor Dushamov

Reputation: 1667

You pass one item - info:

INSERT INTO `operator`(`id`, `operator_name`, `email`, `info`)
VALUES (1,'Bangalink','This is all about Banglalink', NULL),
(2, 'Robi', 'This is all about Robi',NULL);

or

INSERT INTO `operator`(`id`, `operator_name`, `email`)
VALUES (1,'Bangalink','This is all about Banglalink'),
(2, 'Robi', 'This is all about Robi');

Upvotes: 0

Gurwinder Singh
Gurwinder Singh

Reputation: 39477

The provided number of columns in the column list specification and number of column values in each record must match.

Assuming you don't want to insert email data, remove that from the column list:

INSERT INTO `operator`(`id`, `operator_name`, `info`)
VALUES (1,'Bangalink','This is all about Banglalink'),
(2, 'Robi', 'This is all about Robi');

or pass null for email:

INSERT INTO `operator`(`id`, `operator_name`, `email`, `info`)
VALUES (1,'Bangalink',null,'This is all about Banglalink'),
(2, 'Robi', null,'This is all about Robi');

Second method is useful when you may have emails for few records.

Upvotes: 2

Related Questions