三个表之间的外部连接导致 Oracle ORA-01417 错误
Outer join between three tables causing Oracle ORA-01417 error
我们正在尝试 运行 在 table A 和 table 的 B 和 C 之间进行外部连接,但出现错误:
ORA-01417: a table may be outer joined to at most one other table
我们怎样才能让它发挥作用?
查询:
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 (+)
使用正确的显式 join
语法。我认为以下可能是您想要做的:
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;
你可以试试:
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
请避免在 from 子句中使用逗号,而是使用 JOIN 子句。
试试这个:
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
我们正在尝试 运行 在 table A 和 table 的 B 和 C 之间进行外部连接,但出现错误:
ORA-01417: a table may be outer joined to at most one other table
我们怎样才能让它发挥作用?
查询:
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 (+)
使用正确的显式 join
语法。我认为以下可能是您想要做的:
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;
你可以试试:
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
请避免在 from 子句中使用逗号,而是使用 JOIN 子句。
试试这个:
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