SQL Query with and without inner join [duplicate]
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_S开发者_如何学CUBCAT 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?
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."
The first query does have inner joins. In the FROM clause, commas are shorthand for INNER JOIN.
well,
I think the result is the same. But, when your SQL is very large, using INNER JOIN will help you organize the query.
精彩评论