Possible Duplicate:
SQL JOIN: is there a difference between USING, ON or WHERE?
Which is better:
SELECT `sheet_data`.*
FROM `clip`, `sheet_data`
WHERE `clip`.`mrecord`='8' AND `clip`.`data`=`sheet_data`.`id`
or
SELECT `sheet_data`.*
FROM `clip` INNER JOIN `sheet_data`
ON `clip`.`data`=`sheet_data`.`id`
WHERE `clip`.`mrecord`='8'
and why?
In older days, the first was faster, but this is not true anymore. I personally think the INNER JOIN is better, because it is more readable. It shows better the relations between the table. You got those relations in the join, and you do the filtering in the WHERE clause. This separation makes the query more readable. But this is a matter of personal taste.
No. 2 is better for readability, as you can see by looking on the ON clause on which columns you are joining and don't have to scan the whole where clause. But from a performance standpoint, both queries will result in the same execution plan with the same performance.
Generally speaking it's always better to do an explicit join (the second one) because it's more portable. Not all SQL servers implement implicit joins, plus it's easier to tell at a glance what's going on.
精彩评论