【问题标题】:Error code 1054 unknown column `John` in field list 1字段列表 1 中的错误代码 1054 未知列“John”
【发布时间】:2017-06-17 02:14:50
【问题描述】:

我正在尝试添加员工的名字,但我不断收到错误消息。我已经根据我看过的类似问题和视频尝试了更改,但似乎没有任何东西可以摆脱错误。

create table `Employee Information`.`Employee`(
`EmployeeID` int not null,
`EmployeeFirstName` varchar(255) not null,
`EmployeeLastName` varchar(255) not null,
`SupervisorID` int not null,
primary key (`EmployeeID`),
foreign key (`SupervisorID`) references employee (`EmployeeID`)
on delete no action
on update no action
);

insert into `Employee` (EmployeeID, EmployeeFirstName, EmployeeLastName, SupervisorID) values (1, `John`, `Smith`, 52);

有什么帮助吗?

【问题讨论】:

  • 创建表 Employee Information.Employee( EmployeeID int not null, EmployeeFirstName varchar(255) not null, EmployeeLastName varchar(255) not null, SupervisorID int not null,主键 (EmployeeID),外键 (SupervisorID) 引用员工 (EmployeeID) 删除时不执行更新时不执行操作); ::::: 为重复的评论道歉是为了让表格更干净一些。

标签: mysql workbench


【解决方案1】:

您正在使用反引号 (\``) for your values rather than regular quotes ('`)。反引号用于表名和列名。单引号用于值对中的字符串,例如字符串“John”和“Smith”。假设“52”实际上是现有主管,则以下 SQL 语句将起作用:

INSERT INTO `Employee`
  (`EmployeeID`, `EmployeeFirstName`, `EmployeeLastName`, `SupervisorID`)
  VALUES (1, 'John', 'Smith', 52)

【讨论】:

    猜你喜欢
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 2017-06-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 2013-10-13
    • 1970-01-01
    相关资源
    最近更新 更多