在Oracle 11g中,我遇到了查詢錯誤,無法確定它爲什麼會出錯。以下是查詢:select語句出現錯誤,union all都在子查詢中
select
main_data.issue_number,
main_data.transaction_number
from
(
select
p1.payment_date,
p1.media_number,
p1.payment_amount,
p1.issue_number,
p1.advice_na_number,
name.name_address_line_1,
name.name_address_line_2,
name.name_address_line_3,
name.name_address_line_4,
name.name_address_line_5,
name.name_address_line_6,
name.name_address_line_7,
name.name_address_city,
name.state_code,
name.address_country_code,
name.zip_code,
name.tax_id_number,
p1.output_tx_number_prin,
p1.output_tx_number_int,
'' as "transaction_number",
p1header.check_account_number
from
p1
left join name on p1.name_address_number = name.name_address_number
left join p1header on p1.issue_number = p1header.issue_number
UNION ALL
select
check.date_of_payment,
check.media_number,
check.payment_amount,
check.issue_number,
check.payee_na_number,
name.name_address_line_1,
name.name_address_line_2,
name.name_address_line_3,
name.name_address_line_4,
name.name_address_line_5,
name.name_address_line_6,
name.name_address_line_7,
name.name_address_city,
name.state_code,
name.address_country_code,
name.zip_code,
name.tax_id_number,
'' as "output_tx_number_prin",
'' as "output_tx_number_int",
check.transaction_number,
check.dda_number as "check_account_number"
from check
left join name on check.payee_na_number = name.name_address_number
) main_data
選擇上面的單個字段會給我一個「無效的標識符錯誤」。如果我這樣做select *
那麼它會給我回數據沒有任何錯誤。我在這裏做錯了什麼?謝謝。
每當我看到這個錯誤,我假設一個無效的別名。你完全確定你正在使用字段的別名而不是原始的列名嗎?或者,表main_table可能與select語句中使用的不匹配? – user158017
我做過,我甚至在main_data佔位符內部進行了查詢,並運行它而沒有收到錯誤。奇怪的是,當我使用select *時,數據沒有任何錯誤地返回。 –
這是實際的查詢嗎?還是複製品?是否可以提供實際的,未經編輯的查詢?如果可以的話,那可能會幫助我們弄清楚這一點。 – user158017