SQL Server Performance

Left Outer Join

Discussion in 'General Developer Questions' started by danny123, Sep 16, 2008.

  1. danny123 New Member

    Hi there,
    I have 2 tables with foreign key relationship. I am trying to get all the orders for all the customers.In case customer does not have any order it should still be giving result with Null in order field.
    I am using Left Outer Join but i am not getting result for the customers who dont have any orders.
    Any clue?
    Thanks!
  2. SuryaKiran New Member

    Hi Danny,
    Please send me in a basic overview of the table structure so that I could work that out for you.
    Regards,
    Surya
  3. SuryaKiran New Member

    Hi Danny,
    A quick reply could be, if you are using conditions in the WHERE clause try moving them to the Left Outer join . Try this out and let me know, as Conditions in WHERE Clause would result in INNER JOIN based on the conditions you have inputted in the WHERE Clause
  4. danny123 New Member

    Thanks everyone for quick responses but Where clause was causing the issue. I just needed to twick the joins between tables and it worked.
    Thanks!
  5. satya Moderator

    If you can post the code it helps to identify the root cause of the issue than suggesting shot in dark.
  6. FrankKalis Moderator

    [quote user="satya"]
    If you can post the code it helps to identify the root cause of the issue than suggesting shot in dark.
    [/quote]
    Issue already resolved, I guess. [:)]
  7. Madhivanan Moderator

    <P mce_keep="true">[quote user="FrankKalis"] <P>[quote user="satya"]</P><P>If you can post the code it helps to identify the root cause of the issue than suggesting shot in dark. </P><P>[/quote]&nbsp;</P><P>Issue already resolved, I guess. <IMG alt=Smile src="http://sql-server-performance.com/Community/emoticons/emotion-1.gif"> <BR></P><P>[/quote]</P><P>But still there may be chance for improvement if posted [;)]</P><P>I would like to see the problamatic and workable query</P>
  8. Madhivanan Moderator

    [quote user="danny123"]
    Hi there,
    I have 2 tables with foreign key relationship. I am trying to get all the orders for all the customers.In case customer does not have any order it should still be giving result with Null in order field.
    I am using Left Outer Join but i am not getting result for the customers who dont have any orders.
    Any clue?
    Thanks!
    [/quote]
    Post the code you used

Share This Page