这是Employee Table的数据类型和插入的值:
mysql> create table employee (`employee-name` char(30), `street` char(30),
`city` char(30));
mysql> insert into employee values ('John Smith', 'Street A', 'City 1');
mysql> insert into employee values ('Arya Stark', 'Street B', 'City 2');
mysql> insert into employee values ('Barry Allen', 'Street C', 'City 3');
mysql> insert into employee values ('Wanda Maximoff', 'Street D', 'City 4');
mysql> insert into employee values ('Raven Roth', 'Street E', 'City 5');
这是工作表的数据类型和插入的值:
mysql> create table works (`employee-name` char(30), `company-name` char(50),
`salary` decimal(20,2));
mysql> insert into works values ('John Smith', 'MyBank', '10000');
mysql> insert into works values ('Arya Stark', 'First Bank Corporation',
'20000');
mysql> insert into works values ('Barry Allen', 'MyBank', '17000');
mysql> insert into works values ('Wanda Maximoff', 'YourBank', '125000');
mysql> insert into works values ('Raven Roth', 'MyBank', '20000');
我从实验室实际操作中得到的问题是:找到姓名,街道地址, 和在“第一银行”工作的所有员工的居住城市 公司”,收入超过$ 10,000
每次输入此错误都会出现:
select employee.employee-name, employee.street, employee.city from
employee, works
where employee.employee-name=works.employee-name
and company-name = 'First Bank Corporation' and salary > 10000;
ERROR 1054 (42S22): Unknown column 'employee.employee' in 'field list'
答案 0 :(得分:0)
您需要转义包含特殊字符(如-
select employee.`employee-name`...
此外,不再使用旧版联接样式。它在20年前被显式联接所取代。
select e.`employee-name`, e.street, e.city
from employee e
join works w on e.`employee-name` = w.`employee-name`
where `company-name` = 'First Bank Corporation'
and salary > 10000