列数与MySQL中的值计数不匹配

时间:2017-10-23 07:15:14

标签: mysql

每当我尝试在表格中插入数据时:

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

MySQL说:#1136 - 列数与第1行的值计数不匹配

我该如何解决? 我不明白需要做什么。 TIA

2 个答案:

答案 0 :(得分:1)

列列表规范中提供的列数和每个记录中的列值数必须匹配。

假设您不想插入电子邮件数据,请从列列表中删除它:

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

或为电子邮件传递null:

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');

当您收到少量记录的电子邮件时,第二种方法很有用。

答案 1 :(得分:0)

您传递了一个项目 - 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);

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