欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-07-14 10:28:56
...

报错信息

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



相关标签: DB 数据库