将Oracle联接转换为Ansi联接

将Oracle联接转换为Ansi联接

本文介绍了将Oracle联接转换为Ansi联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将以下Oracle sql转换为基于ansi的sql-

I need to convert the following oracle sql to ansi based sql-

Select t1.c1, t2.c2, t1.c3 from t1, t2 where
T1.c1=t2.c1(+) and
T1.c2=t2.c2(+) and
T1.c3=t2.c3 and
T1.c4=t2.c4 and
T1.c1='1'

请帮助

推荐答案

如果t2中的所有列都具有(+)修饰符,则这将是外部联接.

This would be outer join if all columns in t2 had the (+) modifier.

这看起来像:

Select t1.c1, t2.c2, t1.c3
from t1 left join
     t2
     on T1.c1 = t2.c1 and T1.c2 = t2.c2 and
        T1.c3 = t2.c3 and T1.c4 = t2.c4
where T1.c1 = '1';

但是,您的版本是内部联接,因为某些列确实需要匹配-因此第二张表中需要有一个匹配行.

However, your version is an inner join, because some of the columns do need to match -- so there needs to be a matching row in the second table.

因此,真正的等效项只是:

So, the real equivalent is just:

Select t1.c1, t2.c2, t1.c3
from t1 join
     t2
     on T1.c1 = t2.c1 and T1.c2 = t2.c2 and
        T1.c3 = t2.c3 and T1.c4 = t2.c4
where T1.c1 = '1';

(+)不相关.

这篇关于将Oracle联接转换为Ansi联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:49