Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    27

    Unanswered: question of syntax

    Hello All,

    I often see this syntax:

    SELECT a.col1, b.col2, c.col3
    FROM table1 a
    INNER JOIN table2 b ON a.col1 = b.col2
    INNER JOIN table3 c ON b.col2 = c.col3
    WHERE a.col1 = 147

    while some are writing:

    select a.col1, b.col2, c.col3
    from table1 as a,
    table2 as b,
    table3 as c
    where a.col1 = b.col2
    and b.col2 = c.col3
    and a.col1 = 147

    Q1: are there any diffrences ? why should i prefer one syntax above the other ?
    Q2: assume this is the query, should this bring better results:

    select a.col1, b.col2, c.col3
    from table1 as a,
    table2 as b,
    table3 as c
    where a.col1 = 147
    and b.col2 = 147
    and c.col3 = 147

    thanks
    Chanan

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Q1. yes there are differences

    when they are inner joins, the results produced are the same, although the query with INNER JOINs is a lot easier to understand than the one with the old style comma joins

    however, when you need an outer join, the old style comma joins just cannot accomplish it

    Q2. no, same results
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •