我是SQL的新手,我正在编写一个查询,但是我收到了这个错误。任何帮助将不胜感激。
ORA-00933: SQL command not properly ended
我的查询如下:
CREATE VIEW moscow_paris_overlap(SSN) AS
SELECT t1.SSN
FROM assign AS T1
INNER JOIN assign AS T2
ON T1.SSN = T2.SSN
WHERE T1.EndYear = T2.StartYear
AND T1.CityName = 'Moscow'
AND T2.CityName = 'Paris';
SELECT DISTINCT emp.* FROM emp INNER JOIN moscow_paris_overlap ON emp.SSN = moscow_paris_overlap.SSN;
答案 0 :(得分:2)
首先,您需要将CREATE VIEW
与使用它的查询分开。如果您正在使用SQL * Plus或类似的东西,可以通过将/
放在两者之间的单独行上来实现。这将导致首先执行CREATE VIEW
。
其次,在定义表别名时,AS
或FROM
中无法使用INNER JOIN
。将视图创建中的FROM
子句更改为FROM ASSIGN T1
。同样,INNER JOIN
应为INNER JOIN ASSIGN T2
。
分享并享受。