Simple JOIN question

  •  

    In a JOIN statement, I've always seen it look like:

    FROM Table1

    LEFT JOIN Table2 ON Table1.Id = Table2.Id

    Is it possible to have a JOIN like this?

    FROM Table1, Table2

    LEFT JOIN Table2 ON Table1.Id = Table2.Id

    LEFT JOIN Table3 ON Table2.Id = Table3.Id

    Is this even possible?

    Thanks much!

  • Yes but like this :

    FROM Table1

    LEFT OUTER JOIN Table2 ON Table1.Id = Table2.Id

    LEFT OUTER JOIN Table3 ON Table2.id = Table3.Id

  • No, You are mixing the old t-sql join syntax and the ansi join syntax, they can't be mixed, its one or the other.

    Use Pubs

    select *

    from authors a

    join titleauthor b on a.au_id = b.au_id

    select *

    from authors a, titleauthor b

    where a.au_id = b.au_id

    you cannot mix the two different methods

  • Well you can... but you MUST expect errors if you do that, so don't .

  • Thanks guys...

     

    does it need to be a LEFT OUTER JOIN?  Or can I use INNER, LEFT, RIGHT, etc...

     

    thank you!

     

     

  • Any type.

  • In t-sql the Inner, or outer keyword is optional

    inner join is the same as Join

    Left Outer join is the same as left join.

    I'm not sure if the ansi standards require inner/outer keyword

Viewing 7 posts - 1 through 6 (of 6 total)

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