Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Outer Join against two columns works in Ansi but not in Oracle Joins

AdamJan 24 2018 — edited Jan 25 2018

I am sure this has probably been addressed already but after a couple hours of searching I have not found an answer.

I have a query that I need to put into a materialized view.  Materialized views don't support ANSI joins.  Because of this I need to get it into an Oracle outer join syntax.  The ANSI outer join is as follows and returns 50,420 rows.

SELECT A.Field1     Field1,

               A.Field2     Field2,

               A.Field3     Field3,

               A.Field4     Field4,

               B.Field1     Field5

   FROM TableA    a   LEFT OUTER JOIN

               Table B   b 

        ON  a.Field1 = b.Field2

       AND a.Field2 = b.Field3;

When I try to put this into Oracle join syntax I only get 33,713 rows...

SELECT A.Field1     Field1,

               A.Field2     Field2,

               A.Field3     Field3,

               A.Field4     Field4,

               B.Field1     Field5

   FROM TableA     a,

              TableB      bWHERE b.Field2 = a.Field1

       AND b.Field3 = a.Field2

The rows missing are all of the B.Field1 rows that are null because the record doesn't exist in Table B.

I have been fighting this for many hours now.  Any help is very much appreciated.

This post has been answered by AndrewSayer on Jan 24 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 22 2018
Added on Jan 24 2018
10 comments
2,761 views