0

我有 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 命令未正确结束”。

任何帮助或见解将不胜感激!

4

1 回答 1

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
于 2013-02-22T19:44:08.013 回答