Outer join between three tables causing Oracle ORA

2019-08-13 12:18发布

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 (+) 

3条回答
戒情不戒烟
2楼-- · 2019-08-13 13:06

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楼-- · 2019-08-13 13:07

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
查看更多
一夜七次
4楼-- · 2019-08-13 13:23

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 
查看更多
登录 后发表回答