如何解决查询行左连接不匹配 ansi 连接等价行
晚上好,
我有 2 个查询返回不同的行值,一个使用左连接语法,另一个使用旧 ansi
我需要在 oracle 中创建物化视图的语法。我需要添加旧语法 value1 (+) 到
匹配第一个左连接查询(包括空值)。 非常感谢。
观察:发生错误是因为表“detalle_ordenes”具有表“tabla_hija”中不存在的值。但是我 想要显示所有行而不像在左联接查询中那样过滤它
select --(query number 1,returns 18 records.)
o.rowid o_rowid,c.rowid c_rowid,e.rowid e_rowid,f.rowid f_rowid,ordenid,o.detalleid,o.productoid,f.vdescricion as v2descripcion
from detalle_ordenes o
left join tabla_hija c on o.estado=c.vvalor and c.tipo_filtro=1
left join tabla_hija e on o.segmento=e.vvalor and e.tipo_filtro=2
left join tabla_hija f on o.column1=f.vvalor and f.tipo_filtro=3
select --(query number 2,returns 15 records.)
o.rowid o_rowid,f.vdescricion as v2descripcion
from detalle_ordenes o,tabla_hija c,tabla_hija e,tabla_hija f
where
( o.estado=c.vvalor(+) and c.tipo_filtro=1 )
and
( o.segmento=e.vvalor(+) and e.tipo_filtro=2)
and
( o.column1=f.vvalor(+) and f.tipo_filtro=3)
解决方法
将 (+)
添加到外连接过滤器中的所有条件:
select *
from detalle_ordenes o,tabla_hija c,tabla_hija e,tabla_hija f
WHERE o.estado = c.vvalor (+)
AND 1 = c.tipo_filtro (+)
AND o.segmento = e.vvalor (+)
AND 2 = e.tipo_filtro (+)
AND o.column1 = f.vvalor (+)
AND 3 = f.tipo_filtro (+)
dbfiddle here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。