2017-04-10 165 views
0

此查詢引發錯誤ORA-00904: invalid identifier,有人可以告訴我爲什麼嗎?SQL查詢中的無效標識符

select papf.person_id, papf.person_number, ppnf.DISPLAY_NAME 
from per_people_f papf, PER_PERSON_NAMES_F ppnf 
where 
papf.person_id=ppnf.person_id 
and papf.person_id not in (select cs.person_id from cmp_salary cs where cs.person_id is not null and cs.ASSIGNMENT_ID is null) 
and papf.person_id not in (select cse.person_id from cmp_salary_export cs where cse.person_id is not null and cse.ASSIGNMENT_ID is null) 
and ppnf.name_type='US' 
order by papf.person_id 
+0

**您的問題,並添加**完整的**錯誤信息。不要在評論中發佈其他信息。 –

+1

今天提示:切換到現代,明確的'JOIN'語法!易於編寫(沒有錯誤),更易於閱讀和維護,並且在需要時更容易轉換爲外部聯接。 – jarlh

+0

語法有效。好像你拼錯了列或表名。刪除一些東西,然後再試一次。 – jarlh

回答

1

這是一個錯字。在第二個子查詢中,您已將所有列引用別名爲cse.,但您已將表cs別名。

(select cse.person_id 
from cmp_salary_export cs 
where cse.person_id is not null 
and cse.ASSIGNMENT_ID is null) 

用適當的縮進排列代碼不僅僅是簡單:使得它更易於閱讀,因此更易於調試。