我有2个表,EMPLOYEEAPP和EMPLOYEEINFO。
当SECURITYGROUP列为特定值时,我想搜索EMPLOYEEAPP表以查找EMPLOYID。
然后我想从EMPLOYEEAPP表中获取EMPLOYID并使用EMPLOYEEINFO表中的EMPLID列搜索它们对应的名字和姓氏。
SELECT EMPLOYEEAPP.EMPLOYID, EMPLOYEEINFO.FIRST_NAME, EMPLOYEEINFO.LAST_NAME
FROM EMPLOYEEAPP
WHERE EMPLOYEEAPP.SECURITYGROUP = 'ANALYST'
INNER JOIN EMPLOYEEINFO
ON EMPLOYEEAPP.EMPLOYID=EMPLOYEEINFO.EMPLID
我一直收到错误" ORA-00933:SQL命令未正确结束"。
非常感谢任何帮助或见解!
答案 0 :(得分:5)
您的WHERE
子句位置错误。查询应为:
SELECT EMPLOYEEAPP.EMPLOYID,
EMPLOYEEINFO.FIRST_NAME,
EMPLOYEEINFO.LAST_NAME
FROM EMPLOYEEAPP
INNER JOIN EMPLOYEEINFO
ON EMPLOYEEAPP.EMPLOYID=EMPLOYEEINFO.EMPLID
WHERE EMPLOYEEAPP.SECURITYGROUP = 'ANALYST'
查询的顺序是:
SELECT
FROM
JOIN
WHERE
GROUP BY
HAVING
ORDER BY