I need to convert the following Oracle SQL to ANSI 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'
I need to convert the following Oracle SQL to ANSI 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'
This would be outer join if all columns in t2
had the (+)
modifier.
That would look like:
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';
And the (+)
is not relevant.