获取 ORA-00918:列定义不明确:运行 此 SQL:(添加 table 时)

Getting ORA-00918: column ambiguously defined: running this SQL:(When adding a table)

当 运行 这个 SQL 时出现错误 ORA-00918: column ambiguously defined:(当添加 table ra_interface_lines_all 时)

SELECT DISTINCT rcta.TRX_NUMBER
              , rcta.trx_date
              , rcta.PRINTING_OPTION
              , rcta.PRINTING_PENDING
              , rcta.CREATED_FROM
              , houf.NAME  Business_Unit
              , xep.NAME   Legal_Entity
              , rctta.NAME Transaction_Type
              , rcta . invoice_currency_code
              , aaa.gl_date
              , rtb.NAME   Payment_Name
              , hca.account_name
FROM   ra_customer_trx_all        rcta
     , hr_organization_units_f_tl houf
     , xle_entity_profiles        xep
     , ra_terms_tl                rtb
     , RA_CUST_TRX_TYPES_ALL      rctta
     , hz_cust_accounts           hca
     , AR_ADJUSTMENTS_ALL         aaa
     , ra_interface_lines_all
WHERE  trx_number           = 3021
   AND rcta.org_id          = houf.organization_id
   AND xep.legal_entity_id  = rcta.legal_entity_id
   AND rcta.SET_OF_BOOKS_ID = aaa.SET_OF_BOOKS_ID 

当您有多个 table 具有相同的列名并且此列名在没有别名的语句中使用时,会出现此错误。所以解释器无法确定它应该使用哪个table。

要修复您的查询,请检查所有没有别名的列并为其添加前缀。 (例如trx_number

ra_interface_lines_all table 有 trx_number 列存在于其他 table(s) 中,因此您必须引用 table 名称(或别名)柱子。

在你的情况下,如果它是新的 table,你可以更改为:

 , ra_interface_lines_all
   WHERE  ra_interface_lines_all.trx_number           = 3021