ORA-00918:未明确定义列

 

报错如下:

 

 

 

经过一番排查搜索,发现问题出现在Mapper.xml中,问题的原因是三表联合查询的过程中,有些表的字段名称重复,然后由于你没有指定是哪个表的字段,所以它迷路了,对,它迷惑了,它不知道是哪个表的字段,所以报这个错。

举个例子:

A表:student  字段 id,name,age

B表:user      字段uid , name

C表:info       字段oid,level

 

错误语句:由于name字段AB表中一样,所以报错。而id,age虽然没有指定,但是在三表中却是唯一的字段名称,不重复,所以没问题。

select id,name,age from student a,user b,info c where a.id=b.uid and a.id =oid

正确语句:

select id,a.name,age from student a,user b,info c where a.id=b.uid and a.id =oid

 

posted @ 2021-03-16 13:57  万里哥  阅读(727)  评论(0编辑  收藏  举报