SQL Server Performance

Difference betwn JOINS and normal two table joins

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by bab_ganesh, Mar 31, 2008.

  1. bab_ganesh New Member

    Hi,
    Can anyone tell me the actual difference between these queries?
    SELECT * FROM Table1 AS A, Table2 AS B WHERE A.Field1 = B.Field1
    SELECT * FROM Table1 AS A INNER JOIN Table2 AS B ON A.Field1 = B.Field1
    Which query is efficient.? Please tell me, I bet with my friend the INNER JOIN query is faster and efficient than the first one. :)
    Thanks in advance
    Ganesh.

  2. Adriaan New Member

    Check out the execution plans: they should be identical. If the execution plans are identical, the queries are identical.
    In general, you should use JOINs for joining tables, and the WHERE clause for filtering results.
  3. FrankKalis Moderator

    As Adriaan already said, there is no difference between both as long as you're only using INNER JOINs. The optimizer is smart enough to figure that out and will rewrite your query to use an inner join behind the scenes anyway. However, you might want to check this out: http://www.sqlskills.com/blogs/conor/2008/03/29/ONVsWHEREWhereShouldYouPutJoinConditions.aspx

Share This Page