ORA-00918: column ambiguously defined: how to find the column

Daniele picture Daniele · Sep 17, 2012 · Viewed 33k times · Source

I'm getting the classic error:

ORA-00918: column ambiguously defined

Usually, I know how to solve it but my problem now is that I'm working with a 700 row query.

Is there a way to identify the column?

Answer

Ricardo Arnold picture Ricardo Arnold · Sep 18, 2012

Have you tried to do a binary search?

e.g.

If your original query looks like

Select  col1 
       ,col2
       ,col3
       ,col4
from MyTable
  1. you can start with commenting the 2nd half
Select  col1
       ,col2
       /*,col3
       ,col4 */
from MyTable
  1. If you still get the error, run the query again commenting some column from the other half:
Select col1
       /*,col2 */
      ,col3
      ,col4
from MyTable

If you still get an error then your problem is with col1, otherwise you need to change col2.