我正在处理一些SQL开发人员查询,并且我一直收到此错误。我看过网上但我看不清楚为什么我的语法带来“SQL命令没有正确结束错误”。错误显示在“FROM lgemployee as e”的行上。任何正确方向的帮助将不胜感激。
SELECT e.emp_num, emp_lname, emp_fname, sal_amount
FROM lgemployee as e
NATURAL JOIN lgsalary_history
WHERE sal_from = (SELECT min(sal_from))
FROM lgsalary_history as s2
WHERE (e.emp_num = s2.emp_num)
ORDER BY e.emp_num;
答案 0 :(得分:2)
您不能将as
用作表的别名,仅在select语句中使用,例如:
select column as "alias"
from table a
从表格声明中删除as
。它应该运行良好。
答案 1 :(得分:0)
我认为这是错误的括号嵌套 - 尝试
SELECT e.emp_num, emp_lname, emp_fname, sal_amount
FROM lgemployee as e
NATURAL JOIN lgsalary_history
WHERE sal_from = (SELECT min(sal_from)
FROM lgsalary_history as s2
WHERE (e.emp_num = s2.emp_num))
ORDER BY e.emp_num;