Solved

Outer Join with Condition

Posted on 2012-04-02
3
366 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 500 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

856 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