Oracle 跳过多个自然联接中的值
我正在编写一个代码,以更好地格式化我已经确认的使用自然连接的输出。我得到的输出(如下所示)与我使用另一个代码得到的正确输出几乎是完美的,只是它遗漏了连接“内部”的值。我知道在自然连接方法中会跳过这一点,但我不确定如何让它显示出来 使用自然连接代码Oracle 跳过多个自然联接中的值,oracle,Oracle,我正在编写一个代码,以更好地格式化我已经确认的使用自然连接的输出。我得到的输出(如下所示)与我使用另一个代码得到的正确输出几乎是完美的,只是它遗漏了连接“内部”的值。我知道在自然连接方法中会跳过这一点,但我不确定如何让它显示出来 使用自然连接代码 select * from ( select * from ((select part_num, num as a0 from Parts where num = :asm0) natural left
select * from
(
select * from
((select part_num, num as a0 from Parts where num = :asm0)
natural left join
(select part_num, num as a1 from Parts where num = :asm1)
natural left join
(select part_num, num as a2 from Parts where num = :asm2)
natural left join
(select part_num, num as a3 from Parts where num = :asm3))
where a1 is null or a2 is null or a3 is null
union
select * from
((select part_num, num as a0 from Parts where num = :asm0)
natural right join
(select part_num, num as a1 from Parts where num = :asm1)
natural right join
(select part_num, num as a2 from Parts where num = :asm2)
natural right join
(select part_num, num as a3 from Parts where num = :asm3))
where a0 is null
)
我得到了输出
Number A0 A1 A2 A3
351-2927-060 944-3234-016 944-3234-212 944-3234-242
351-2930-330 944-3234-010 944-3234-212
351-2930-430 **Should have 016 here** 944-3234-242
351-3487-344 944-3234-212 944-3234-242
使用我知道的不同代码返回我得到的正确输出
Number A's
351-2927-060 944-3234-242
351-2930-330 944-3234-010
351-2930-330 944-3234-212
351-2930-430 944-3234-016 shows the missing number
351-2930-430 944-3234-242
351-3487-344 944-3234-212
351-3487-344 944-3234-242
有没有一种方法可以让我用自然连接的方法来显示这个值呢?最近学过这个,但是有一种完全连接的方法可以完成我想做的事情
select * from
(
(select part_num, num as a0 from Parts where num = :asm0)
natural full join
(select part_num, num as a1 from Parts where num = :asm1)
natural full join
(select part_num, num as a2 from Parts where num = :asm2)
natural full join
(select part_num, num as a3 from Parts where num = :asm3)
)
where a0 != any(a1,a2,a3) or a1 != any (a2,a3) or a2 != any(a3)