为什么在尝试创建数据并将数据插入新 table 时收到错误 1241(在 phpMyAdmin 上)?

Why do I receive error 1241 when trying to Create and Insert data into a new table (on phpMyAdmin)?

我正在尝试创建一个新的 table 并向其中插入值,但我一直收到“#1241 - 操作数应包含 1 列”。 请有人帮助确定我的代码有什么问题,因为我不确定这个错误指的是什么?

我在 SQL 选项卡下插入 phpMyAdmin 数据库的代码。我试图删除自动递增属性并尝试查看其他示例来检查我的语法,但我无法发现问题。对此提供一些指导将不胜感激。

我输入的代码是这样开头的:

# AppSoft Project - Greg Roberts

DROP table if exists Department;
DROP table if exists Role;
DROP table if exists User;
DROP table if exists Appraisal;
DROP table if exists Question;
DROP table if exists Answer;

CREATE table Department(
    DeptID int NOT NULL AUTO_INCREMENT,
    DeptName varchar(30) NOT NULL,
    primary key (DeptID));

INSERT into Department values(
    (00, 'SuperAdmin'),
    (01, 'Support Staff'),
    (02, 'Teaching Staff'),
    (03, 'SLT'));

CREATE table Role(
    RoleID int NOT NULL AUTO_INCREMENT,
    RoleTitle varchar(30) NOT NULL,
    primary key (RoleID));

INSERT into Role values(
    (00, 'SuperAdmin'),
    (01, 'Office Administrator'),
    (02, 'Teaching Partner'),
    (03, 'Mid Day Supervisor'),
    (04, 'Cooks'),
    (05, 'Cleaners'),
    (06, 'Maintenance'),
    (07, 'Teacher'),
    (08, 'Department Head'),
    (09, 'SENCO'),
    (10, 'Head Teacher'),
    (11, 'Executive Head'));

Error Code that Occurs

如果主键设置为 auto_increment,则无需插入主键。

DeptID int NOT NULL AUTO_INCREMENT

只需插入部门名称,Values 不需要额外的大括号。

INSERT into Department( DeptName) values 
('SuperAdmin'),
('Support Staff'),
('Teaching Staff'),
('SLT');

您也需要对角色 table 执行相同的操作。

此外,如果您尝试将 0 插入主键,它实际上会插入 1 您可以在 Standard Docs

中阅读相关信息

您似乎遇到了错误,因为您的第一条记录将 1 插入 table,然后您的第二条记录尝试在主键列中再次插入 1