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!

Stuck trying to convert JOIN / LEFT JOIN SQL to ( + ) format

user16854Oct 5 2010 — edited Oct 13 2010
We used to have a member of staff in our team who used to write his SQLs using JOIN syntax.

So rather than:
SELECT tbl1.this, tbl2.that
FROM tbl1, tbl2
WHERE tbl1.fldID = tbl2.otherID
He did:
SELECT tbl1.this, tbl2.that
FROM tbl1 JOIN tbl2
ON tbl1.fldID = tbl2.otherID
And the same with LEFT JOIN - he'd use LEFT JOIN rather than use the ( + ) syntax.

I've got to rework some of his SQL, but I am really stuck trying to convert it to the ( + ) type syntax with which I'm more familiar. I know that if I was smarter I should just be able to use his JOIN type SQL, but I find it v. confusing.

This is an example of his SQL:
SELECT frv.application_id
     , frv.responsibility_id
     , frv.responsibility_name
     , mug.GROUP_ID
  FROM apps.fnd_responsibility_vl frv JOIN xxmv.mv_user_group mug
       ON SYSDATE BETWEEN frv.start_date AND NVL(frv.end_date, SYSDATE)
     AND (
             frv.responsibility_name LIKE '%Purchasing User'
          OR frv.responsibility_name LIKE '%Purchasing Manager'
          OR frv.responsibility_name LIKE '%Purchasing Receiver'
          OR frv.responsibility_name LIKE '%PO User'
          OR frv.responsibility_name LIKE '%PO Manager'
          OR frv.responsibility_name LIKE '%PO Receiver'
          OR frv.responsibility_name LIKE '%Web Req%'
         )
       LEFT JOIN xxmv.mverp_resp_group mrg
       ON mrg.GROUP_ID = mug.GROUP_ID
     AND frv.responsibility_id = mrg.responsibility_id
     AND frv.application_id = mrg.application_id
 WHERE mrg.GROUP_ID IS NULL;
I wondered if I could please ask for advice on how I could convert this SQL to the ( + ) format, as I can't work out which parts of the SQL relate to which join, as it doesn't feel very logical. Apologies if this appears lazy - I really have spent hours on this already, trying to compare my botched SQL to his SQL, to get the same output, but so far, to no avail. For example, his SQL returns 111,080 rows.

I tried with:
--without LEFT_JOIN TEST AGAIN
SELECT *
  FROM (SELECT frv.application_id
             , frv.responsibility_id
             , frv.responsibility_name
             , mug.group_name
             , mug.GROUP_ID
          FROM apps.fnd_responsibility_vl frv
             , xxmv.mv_user_group mug
         WHERE SYSDATE BETWEEN frv.start_date AND NVL(frv.end_date, SYSDATE)) big_list
     , xxmv.mverp_resp_group mrg
 WHERE big_list.GROUP_ID = mrg.GROUP_ID(+)
   AND big_list.responsibility_id = mrg.responsibility_id(+)
   AND big_list.application_id = mrg.application_id(+)
   AND (
           big_list.responsibility_name LIKE '%Purchasing User'
        OR big_list.responsibility_name LIKE '%Purchasing Manager'
        OR big_list.responsibility_name LIKE '%Purchasing Receiver'
        OR big_list.responsibility_name LIKE '%PO User'
        OR big_list.responsibility_name LIKE '%PO Manager'
        OR big_list.responsibility_name LIKE '%PO Receiver'
        OR big_list.responsibility_name LIKE '%Web Req%'
       );
But that returns 116,316 rows...

Any advice much appreciated.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2010
Added on Oct 5 2010
12 comments
1,099 views