报错信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS t1
报错原因
习惯性用了小括号
源代码是这样的
CREATE VIEW view1 AS
SELECT t1.essn,t1.ename,t1.address,t1.dname
FROM (department NATURAL JOIN employee) AS t1
WHERE t1.dname='Produce Department';
修改方法
多select一层就好了
CREATE VIEW view1 AS
SELECT t1.essn, t1.ename, t1.address, t1.dname
FROM (
SELECT *
FROM department
NATURAL JOIN employee) AS t1
WHERE t1.dname = 'Produce Department';