5

Possible Duplicate:
Is it better to do an equi join in the from clause or where clause

I'm a noob in SQL,i have 2 queries:

SELECT 
    A.COLUMN1,B.COLUMN2, C.COLUMN3
FROM
     TB_ITEM A,
     TB_ITEM_CAT B,
     TB_ITEM_SUBCAT C
WHERE
     A.COLUMN1 = B.COLUMN1
     AND A.COLUMN1 = c.COLUMN1

and

SELECT 
    A.COLUMN1,B.COLUMN2, C.COLUMN3
FROM
     TB_ITEM A 
INNER JOIN TB_ITEM_CAT B on A.COLUMN1 = B.COLUMN1
INNER JOIN TB_ITEM_SUBCAT C on A.COLUMN1 = C.COLUMN1

In first query,we dont have INNER JOINS,and select from 3 tables. In the second,we have the same query with INNER JOINS,and select from 3 tables.

They are supposed to show same result? What the difference beetween these queries?

Community
  • 1
  • 1
ozsenegal
  • 4,055
  • 12
  • 49
  • 64
  • 4
    ANSI-89 vs ANSI-92. No difference in performance. See [Explicit vs implicit SQL joins](http://stackoverflow.com/questions/44917/explicit-vs-implicit-sql-joins) – Martin Smith Oct 11 '11 at 14:42
  • Are you seeing any difference in the results? I would expect them to be identical. This question is very similar to http://stackoverflow.com/questions/7686190/mysql-query-perfomance-which-one-is-best , although that was specifically concerned with performance on MySQL. –  Oct 11 '11 at 14:43

3 Answers3

5

They are semantically the same. A decent optimizer will recognize this an generate equally efficient plans. An experienced SQL coder will also recognize this ;)

Joe Celko quote, "There are at least seven ways to write a query; only two are worth using."

onedaywhen
  • 55,269
  • 12
  • 100
  • 138
1

The first query does have inner joins. In the FROM clause, commas are shorthand for INNER JOIN.

0

well,

I think the result is the same. But, when your SQL is very large, using INNER JOIN will help you organize the query.

eliangela
  • 253
  • 2
  • 5
  • 21