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
from SEC_SEAL_LOG,SEC_WRITING_OFF_SEALS
– RiggsFollySELECT table_name.columns_name FROM table_name
("fully" qualified as the database name also can be included which makes itSELECT database_name.table_name.columns_name FROM table_name
) or useSELECT alias_name.column_name FROM table_name AS alias_name
(aliased) – Raymond NijlandJOIN
instead of the old comma JOIN.. Topicstarter i assume you didn't notice your SQL is a Cartesian Product between SEC_SEAL_LOG and SEC_WRITING_OFF_SEALS before that result is filterd ? i am pretty sure that query could be (re)written better if you share the data and expected results... See Why should I provide a Minimal Reproducible Example for a very simple SQL query? – Raymond Nijland