Andrii Havrylyak
Andrii Havrylyak

Reputation: 675

Unable to join two oracle tables

i have 2 tables. First table SEC_SEAL_LOG with columns:

DATA_ADD,
DATA_AREA,
SEAL_NUMBER,
DATA_SEALING,
DATA_UNPLUG,
SORRUPTED.
SEC_WRITING_OFF_SEALS 

second table with columns:

DATA, SEAL.

I want to put these 2 tables together, but I cannot understand where I have the error, I will be grateful for your help.

select DATA_ADD,
       DATA_AREA,
       SEAL_NUMBER,
       DATA_SEALING,
       DATA_UNPLUG,
       СORRUPTED,
       Data
from SEC_SEAL_LOG,SEC_WRITING_OFF_SEALS
where  (data_area = (select data_area 
                     from SEC_USERS_LIST 
                     where login = LOWER(:APP_USER) 
                     and SEAL_NUMBER = SEAL 
                    )
            or 20 >= (select u.role 
                      from SEC_users_list u 
                      where u.login = lower(:APP_USER)
                    )
        ) 
and СORRUPTED = 'Так'  
and SEAL_NUMBER = SEAL
ORDER BY  data_add DESC

I amd getting this error

ORA-20999: Failed to parse SQL query!

ORA-06550: line 7, column 4: ORA-00918: column ambiguously defined

Upvotes: 0

Views: 203

Answers (1)

bk_32
bk_32

Reputation: 529

The error Column Ambiguously Defined occurs when a column name is present in more than one table, and you have failed to specify which table.

You are doing that in this line: and SEAL_NUMBER = SEAL (which you have twice).

From which table to you want to compare that SEAL value?

Write it as SEC_SEAL_LOG.SEAL or SEC_WRITING_OFF_SEALS.SEAL or whatever table name you are trying to compare this value from, and it will get rid of the Column Ambiguously Defined error.

Upvotes: 1

Related Questions