What to use where or inner join?
Actually, I received a question like this few days ago and if such a question appear to people why not to right the answer here. :) If you have two queries like those below what do you think is the difference?
1: select count(a.id)
2: from answer a, answerset aset
3: where a.answersetId = aset.id and aset.isReviewed = 1
1: select count(a.id)
2: from answer a
3: inner join answerset aset on a.answersetId = aset.id
4: where aset.isReviewed = 1
Logically, there is no difference. They will return the same result and the execution plan will be the same and it is obvious that the performance will be also the same. The execution plan is below. You can see that both queries share 50% of the query cost.
Then what to use? I think it is up to you and up to the coding styles that you may follow in your team. If your team prefer to use where just do it or vice versa.
May 20th, 2010 at 10:58 pm
Thanks for the answer