无法加入两个Oracle表 [英] Unable to join two oracle tables
问题描述
我有2张桌子. 第一个表SEC_SEAL_LOG的列:
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
带有列的第二个表:
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
我会收到此错误
ORA-20999:无法解析SQL查询!
ORA-06550:第7行,第4列:ORA-00918:列定义不明确
ORA-20999: Failed to parse SQL query!
ORA-06550: line 7, column 4: ORA-00918: column ambiguously defined
推荐答案
当一个列名称存在于多个表中而您未能指定哪个表时,将发生错误Column Ambiguously Defined
.
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.
您正在执行以下操作:and SEAL_NUMBER = SEAL
(您有两次).
You are doing that in this line: and SEAL_NUMBER = SEAL
(which you have twice).
您要从哪个表中比较该SEAL值?
From which table to you want to compare that SEAL value?
将其写为SEC_SEAL_LOG.SEAL
或SEC_WRITING_OFF_SEALS.SEAL
或任何试图与之比较的表名,它将消除Column Ambiguously Defined
错误.
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.
这篇关于无法加入两个Oracle表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!