Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Outer Join with Condition

Posted on 2012-04-02
3
Medium Priority
?
372 Views
Last Modified: 2012-07-16
i am joining 2 tables ..... here i am writing the query

SELECT A.*,B.*
FROM MATL_MSTR A,
         MATL_PROD B,
         MATL_DISPATCH C
WHERE A.MATL_ID = B.MATL_ID AND
            A.MATL_ID = C.MATL_ID(+);

Here i want to put one more condition with the outer join table (MATL_DISPATCH) i.e C.matl_sts = '75'.

IF i am directly using this condition then i am not getting all matl_id. Please help me and explain me how to use a condition in outer join table and that should be executed only when the outer join table has the data for that matl_id.
0
Comment
Question by:chinmaya224
3 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 37799561
Not get what exactly you want
but as per understaning you want to include the data from table  MATL_DISPATCH C
if it excists with condition C.matl_sts = '75'

then try this

SELECT A.*,B.* , C.*
FROM MATL_MSTR A Inner join
         MATL_PROD B on A.MATL_ID = B.MATL_ID,
         Left join MATL_DISPATCH C On A.MATL_ID = C.MATL_ID and C.matl_sts = '75'
0
 
LVL 1

Accepted Solution

by:
leclaude earned 1000 total points
ID: 37800948
Put Matl_Dispatch in a subquery.  This should do the trick.

SELECT A.*,B.*
FROM MATL_MSTR A,
         MATL_PROD B,
         (SELECT * FROM MATL_DISPATCH C WHERE C.MATL_STS='75') C
WHERE A.MATL_ID = B.MATL_ID AND
            A.MATL_ID = C.MATL_ID(+)
0
 

Author Closing Comment

by:chinmaya224
ID: 38190780
Thank You ..
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question