Outer join between three tables causing Oracle ORA-01417 error

别等时光非礼了梦想. 提交于 2019-12-24 15:34:48

问题


We're trying to run an outer join between table A on both tables B and C but get the error:

ORA-01417: a table may be outer joined to at most one other table

How can we get this to work?

Query:

select a.xxx, a.yyy, b.col1, c.col1 from a, b, c
where
a.xxx = b.xxx (+) and 
a.yyy = b.yyy (+) and
a.xxx = c.xxx (+) and 
a.yyy = c.yyy (+) 

回答1:


Please refrain from using comma in the from clause and use the JOIN clause instead.

Try using this:

select a.xxx, a.yyy, b.col1, c.col1 
from a LEFT JOIN b ON a.xxx = b.xxx AND a.yyy = b.yyy
       LEFT JOIN c ON a.xxx = c.xxx AND a.yyy = c.yyy 



回答2:


Use proper explicit join syntax. I think the following is probably what you want to do:

select a.xxx, a.yyy, b.col1, c.col1
from a left join
     b
     on a.xxx = b.xxx and a.yyy = b.yyy left join
     c
     on a.xxx = c.xxx and a.yyy = c.yyy;



回答3:


You could try:

select a.xxx, y.xxx, b.col1, c.col2
from a
left join b on a.xxx = b.xxx and a.yyy = b.yyy
left join c on a.xxx = c.xxx and a.yyy = c.yyy


来源:https://stackoverflow.com/questions/34303534/outer-join-between-three-tables-causing-oracle-ora-01417-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!