gpt4 book ai didi

mysql - 插入列正确的数据时,MySQL 中出现错误 1136

转载 作者:行者123 更新时间:2023-11-29 17:44:06 25 4
gpt4 key购买 nike

我正在为一个学校项目开发一个数据库,每次我将数据插入表中时,我都会得到以下信息。

Error Code: 1136. Column count doesn't match value count at row 1

我发现这是由值后面的行与表本身的值数量不同引起的。在我的数据库中,我已经验证了行数是否有效。

为了使其更短,我只包含一张表的信息,但我拥有的所有表都发生这种情况。

DROP schema if exists `ACRS`;
CREATE SCHEMA IF NOT EXISTS `ACRS` DEFAULT CHARACTER SET utf8;
USE `ACRS`;

DROP TABLE IF EXISTS ComputerDetails;
CREATE TABLE IF NOT EXISTS ComputerDetails (
`ComputerNumber` INT NOT NULL,
`ComputerYear` INT NULL,
`ComputerModel` VARCHAR(45) NULL,
`CPUModel` VARCHAR(25) NULL,
`HasMonitor` CHAR(1) NULL,
`NumOfUSB` INT NULL,
`HardDriveCapGB` INT NULL,
`NetworkCardType` VARCHAR(45) NULL,
`OperatingSystem` VARCHAR(45) NULL,
`HasWebcam` CHAR(1) NULL,
PRIMARY KEY (`ComputerNumber`))
ENGINE = InnoDB;

INSERT INTO ComputerDetails
( ComputerNumber, ComputerYear, ComputerModel, CPUModel, HasMonitor, NumOfUSB, HardDriveCapGB, NetworkCardType, OperatingSystem, HasWebCam)
values(
( 0101, 2008, 'Dell Optoplez 980', 'Intel', 'Y', 3, 100, 'Both', 'Windows', 'Y'),
( 0102, 1985, 'IBM PS2', 'Intel' 'N', 0, 0, 'Wireless', 'Unix', 'Y'),
( 0103, 2011, 'Apple MacBook Pro', 'Intel' 'Y', 2, 100, 'Both', 'Mac', 'N'),
( 0104, 2011, 'Apple MacBook Pro', 'Intel' 'N', 4, 1000, 'Wired', 'Windows', 'N'),
( 0105, 2014, 'Toshiba Satellite P50A', 'AMD' 'Y', 2, 150, 'Wireless', 'Linux', 'Y'),
( 0106, 2013, 'VersaPro type VC' 'Intel', 'Intel' 'Y', 3, 105, 'Both', 'Unix', 'N'),
( 0107, 1999, 'Power Mac G3', 'Power PC' 'N', 3, 5, 'Both', 'Mac', 'Y'),
( 0108, 2007, 'Mac Pro', 'Intel' 'Y', 4, 200, 'Wireless', 'Mac', 'N'),
( 0109, 2000, 'Power Mac x86', 'Intel' 'Y', 4, 600, 'Wired', 'Windows', 'Y'),
( 0110, 2018, 'Apple iMac 4K', 'Intel' 'Y', 3, 50000, 'Both', 'Mac/Windows', 'Y'),
( 0111, 2013, 'VersaPro type VC', 'AMD' 'Y', 3, 640, 'Both', 'Unix', 'Y'),
( 0112, 2016, 'iMac', 'Intel' 'Y', 4, 630, 'Wireless', 'Unix', 'Y'),
( 0113, 2013, 'VersaPro type VC', 'Intel' 'Y', 3, 250, 'Wired', 'Windows', 'N'),
( 0114, 2015, 'Sony VAIO Z', 'Intel' 'Y', 17, 2, 'Both', 'Mac', 'N'),
( 0115, 1999, 'Power Mac G3', 'Power PC' 'N', 2, 30, 'Wired', 'Mac', 'N'),
( 0116, 2013, 'VersaPro type VC', 'Intel' 'Y', 4, 350, 'Both', 'Windows', 'Y'),
( 0117, 2008, 'Dell Optoplez 980', 'Intel' 'Y', 3, 150, 'Both', 'Linux', 'Y'),
( 0118, 2008, 'Dell Optoplez 980', 'Intel' 'Y', 1, 200, 'Wireless', 'Linux', 'Y'),
( 0119, 2010, 'Toshiba Satellite 750', 'Intel' 'Y', 2, 140, 'Both', 'Unix', 'Y'),
( 0120, 2018, 'HP Z2 Mini G3', 'AMD' 'Y', 3, 500, 'Wired', 'Unix', 'N')
);

最佳答案

通过删除 VALUES 中的额外左括号和右括号来尝试以下查询,首先在 PhpMYAdmin 上运行它...希望这有帮助

INSERT INTO ComputerDetails
( ComputerNumber, ComputerYear, ComputerModel, CPUModel, HasMonitor, NumOfUSB, HardDriveCapGB, NetworkCardType, OperatingSystem, HasWebCam)
values
( 0101, 2008, 'Dell Optoplez 980', 'Intel', 'Y', 3, 100, 'Both', 'Windows', 'Y'),
( 0102, 1985, 'IBM PS2', 'Intel' 'N', 0, 0, 'Wireless', 'Unix', 'Y'),
( 0103, 2011, 'Apple MacBook Pro', 'Intel' 'Y', 2, 100, 'Both', 'Mac', 'N'),
( 0104, 2011, 'Apple MacBook Pro', 'Intel' 'N', 4, 1000, 'Wired', 'Windows', 'N'),
( 0105, 2014, 'Toshiba Satellite P50A', 'AMD' 'Y', 2, 150, 'Wireless', 'Linux', 'Y'),
( 0106, 2013, 'VersaPro type VC' 'Intel', 'Intel' 'Y', 3, 105, 'Both', 'Unix', 'N'),
( 0107, 1999, 'Power Mac G3', 'Power PC' 'N', 3, 5, 'Both', 'Mac', 'Y'),
( 0108, 2007, 'Mac Pro', 'Intel' 'Y', 4, 200, 'Wireless', 'Mac', 'N'),
( 0109, 2000, 'Power Mac x86', 'Intel' 'Y', 4, 600, 'Wired', 'Windows', 'Y'),
( 0110, 2018, 'Apple iMac 4K', 'Intel' 'Y', 3, 50000, 'Both', 'Mac/Windows', 'Y'),
( 0111, 2013, 'VersaPro type VC', 'AMD' 'Y', 3, 640, 'Both', 'Unix', 'Y'),
( 0112, 2016, 'iMac', 'Intel' 'Y', 4, 630, 'Wireless', 'Unix', 'Y'),
( 0113, 2013, 'VersaPro type VC', 'Intel' 'Y', 3, 250, 'Wired', 'Windows', 'N'),
( 0114, 2015, 'Sony VAIO Z', 'Intel' 'Y', 17, 2, 'Both', 'Mac', 'N'),
( 0115, 1999, 'Power Mac G3', 'Power PC' 'N', 2, 30, 'Wired', 'Mac', 'N'),
( 0116, 2013, 'VersaPro type VC', 'Intel' 'Y', 4, 350, 'Both', 'Windows', 'Y'),
( 0117, 2008, 'Dell Optoplez 980', 'Intel' 'Y', 3, 150, 'Both', 'Linux', 'Y'),
( 0118, 2008, 'Dell Optoplez 980', 'Intel' 'Y', 1, 200, 'Wireless', 'Linux', 'Y'),
( 0119, 2010, 'Toshiba Satellite 750', 'Intel' 'Y', 2, 140, 'Both', 'Unix', 'Y'),
( 0120, 2018, 'HP Z2 Mini G3', 'AMD' 'Y', 3, 500, 'Wired', 'Unix', 'N');

关于mysql - 插入列正确的数据时,MySQL 中出现错误 1136,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49880414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com