ORA-00918:列定义不明确,我收到此错误 [英] ORA-00918: column ambiguously defined i am getting this error

查看:160
本文介绍了ORA-00918:列定义不明确,我收到此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT
    c.CONSOL_INVOICE,
    cu.name,
    cu.CUST_CODE,
    c.bu_name, 
    cLang.name
FROM CONSL_INV c 
LEFT JOIN customers cu ON c.cust_code = cu.CUST_CODE,
    customers_lang cLang 
WHERE 
    upper(cLang.NAME) LIKE ?  
    AND upper(cLang.LANGUAGE_CD) = ? 
    AND c.CUST_CODE = cLang.CUST_CODE

此查询在Oracle Sql Developer中正确执行,但在休眠状态下不执行.

This Query Executes Correctly In Oracle Sql Developer but it does not execute in hibernate.

它给出了以下错误:

"ORA-00918:列定义不明确"

"ORA-00918: column ambiguously defined"

我知道这是因为多个列具有相同的名称,但是我已经正确地做到了,但是仍然不知道为什么它不能在休眠状态下执行.

I know it's because of multiple columns having same name, but I have done it correctly but still don't know why it's not executing in hibernate.

推荐答案

其他建议使用别名:

select c.consol_invoice
      ,cu.name as name1
      ,cu.cust_code
      ,c.bu_name
      ,clang.name as name2
  from consl_inv c
  left join customers cu
    on c.cust_code = cu.cust_code, customers_lang clang
 where upper(clang.name) like ?
   and upper(clang.language_cd) = ?
   and c.cust_code = clang.cust_code

如您所见,我已经为选定的列cu.name和clang.name添加了别名,以便查询结果具有两个不同的列.

As you can see I've added aliases to the selected columns cu.name and clang.name so that the query result has two different columns.

这篇关于ORA-00918:列定义不明确,我收到此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆