2013-02-22 117 views
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

你在錯誤的地方有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 
+0

現在我得到 「ORA-01722:無效號碼」,任何想法? – user2100620 2013-02-22 19:51:54

+1

「EMPLOYID」,「EMPLID」和「SECURITYGROUP」的數據類型是什麼? – Taryn 2013-02-22 19:54:48

+0

僱員人數:NUMBER; SECURITYGROUP:VARCHAR2(); EMPLID:VARCHAR2() – user2100620 2013-02-22 20:10:48