Advertisement

09.17.2003 at 08:33AM PDT, ID: 20741411
[x]
Attachment Details

Oracle 9i OUTER JOIN syntax

Asked by cressi in Oracle Product Info

Tags: oracle, join, outer, syntax

Hello all,

Here is the original SQL statement that did not need OUTER JOIN functionality, very basic all INNER:
SELECT  DISTINCT
a.group_id,
a.workorder_no,
b.assignment_no,
d.document_no,
d.source,
b.assignment_type,
b.assignment_class,
b.setid,
b.service_cust_id,
b.service_addr_num,
d.image_file_name,
b.start_dt,
b.end_dt,
d.week_end_dt,
b.business_type
FROM sysadm.ps_pb_wkord a,
sysadm.ps_pb_wkord_assig b,
sysadm.ps_pb_ts_control c,
sysadm.ps_pb_ts_header d
WHERE a.group_id = b.group_id
AND a.workorder_no = b.workorder_no
AND a.group_id = c.group_id
AND b.assignment_no = c.assignment_no
AND c.group_id = d.group_id
AND c.control_no = d.control_no


However, now the business rules need an outer join on the join of  'b.assignment_no = c.assignment_no' to retrieve assignments
that are in b but no match in c.  OUTER JOIN, right?.  Seperate queries against the tables prove that there are quite a few records in table b that are not in table c.  Here is the new query with the OUTER JOIN that I thought would remedy this:

SELECT DISTINCT
a.group_id,
a.workorder_no,
b.assignment_no,
d.document_no,
d.source,
b.assignment_type,
b.assignment_class,
b.setid,
b.service_cust_id,
b.service_addr_num,
d.image_file_name,
b.start_dt,
b.end_dt,
d.week_end_dt,
b.business_type
FROM sysadm.ps_pb_wkord_assig b
LEFT OUTER JOIN
sysadm.ps_pb_ts_control c
ON
b.assignment_no = c.assignment_no,
sysadm.ps_pb_wkord a,  
sysadm.ps_pb_ts_header d
WHERE a.group_id = b.group_id
AND a.workorder_no = b.workorder_no
AND a.group_id = c.group_id
AND c.group_id = d.group_id
AND c.control_no = d.control_no

This query however produces the exact same results as the query without the OUTER JOIN.  Is the problem that the other tables involved that do not have to be OUTER JOINED need to use the new 9i INNER JOIN syntax?  Basically, how do you OUTER JOIN some tables while INNER JOINING the others.  Thanks.Start Free Trial
[+][-]09.17.2003 at 09:18AM PDT, ID: 9379316

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2003 at 09:48AM PDT, ID: 9379592

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.17.2003 at 09:52AM PDT, ID: 9379635

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2003 at 10:11AM PDT, ID: 9379795

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.17.2003 at 10:50AM PDT, ID: 9380112

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2003 at 11:11AM PDT, ID: 9380287

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2003 at 12:45AM PDT, ID: 9391781

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Product Info
Tags: oracle, join, outer, syntax
Sign Up Now!
Solution Provided By: li_bao
Participating Experts: 3
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32