Join three tables and

  • rbarryyoung (9/30/2008)


    Wouldn't you want to do it like this?:

    SELECT *

    FROM table1

    LEFT JOIN (table2 INNER JOIN table3 ON table3.fkey = table2.Pkey)

    ON table2.fkey = table1.Pkey

    Absolutely, if you want to maintain the outer join, but need the inner join between the other two tables. I was mainly focusing on the fact that using the deprecated joins was not going to work in SQL Server 2005 (unless compatibility mode is set to 80).

    The above is another example of how you can build your joins and the join is very clear using the ANSI join syntax. Using the older syntax, I am not sure even how the above would be done.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Lynn Pettis (9/30/2008)


    Looking back at the sample data provided, nope. Need to have an outer join between table2 and table3.

    Sorry, Lynn, I was just talking about the transformation from one query syntax to another. I was not referring to solving the original question or looking at the original data.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply