我有一個像瞭解基本的SQL查詢
SELECT tran_number
FROM table_a WHERE customer_id IN
(SELECT customer_id
FROM table_b
WHERE customer_key = 89564
AND ( other_phn_area_code
|| other_phnum_pfx_num
|| other_phnum_sfx_num IN
(123456789)))
AND phn_area_code || phnum_pfx_num || phnum_sfx_num IN (123456789)
上面的代碼工作正常查詢。值得關注的是與內部查詢(複製下面單獨內部查詢)...
(SELECT customer_id
FROM table_b
WHERE customer_key = 89564
AND ( other_phn_area_code
|| other_phnum_pfx_num
|| other_phnum_sfx_num IN
(123456789)))
當我執行此查詢時,我得到錯誤的customer_id: invalid identifier
。實際上,table_b
沒有任何名爲customer_id
的字段。如果是這樣,那麼它是如何工作的,沒有任何問題,當我用它作爲上面的內部查詢。
請幫我理解這一點。
下面
Oracle 11G Enterprise edition 11.2.0.2.0
PL/SQL Release 11.2.0.2.0
你是什麼意思的「上面的代碼工作正常。」 - 它返回給你一些輸出,但是你真正想用這個查詢來實現什麼?你試圖從customer_id滿足的行中獲得tran_number - 什麼? – 2012-07-17 08:19:18