You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

报错信息

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';



上一篇:MySQL数据库优化


下一篇:汇总字段介绍以及在汇率变化后货币数据类型的汇总字段怎么变的实践研究