3

Possible Duplicate:
Inner join vs Where

Hello in many interviews they ask which is more efficient , inner join or where clause? How to justify an tell an answer for such a scenario?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Evlikosh Dawark
  • 610
  • 2
  • 11
  • 24
  • 2
    http://stackoverflow.com/questions/121631/inner-join-vs-where is a good discussion of this. – dash Dec 13 '11 at 12:13
  • that s a good one . Thank you – Evlikosh Dawark Dec 13 '11 at 12:19
  • IMO depends on the database versions; which can result in different execution plans. To answer the question directly I would simply say depending on database version, you'd have to run some Queries see some execution plans and find out. inner joins are the new ansi standard however using non-ansi joins was the standard for many years; thus your likely to encounter both in a long established environment; both typically work and work well because engines compile them to the same execution plans. But to be certain you'd have to check both statements plans. – xQbert Dec 13 '11 at 12:20
  • Also, the older `,` notation is a pain in the arse to understand and debug. It's not a consensus, but the great majority agree that using `,` notation is bad practice. – MatBailie Dec 13 '11 at 12:27

2 Answers2

2

Both are same as per execution Plan, but can increase readability by using join. Best practice is to use join

Nighil
  • 4,099
  • 7
  • 30
  • 56
  • is there a way to prove both are the same? any logical explanation? – Evlikosh Dawark Dec 13 '11 at 12:36
  • I try to answer :) Both queries must return the same result set, so in the ideal conditions the query optimizer must produce the same execution plan. Sometimes (very complex query, not updated statistics and so on) the query optimizer can fail and produce not optimal execution plan in one of the two queries (or in both of them) – ceth Dec 13 '11 at 13:23
  • But I don't know any sources which recommend to use 'join' ower 'where' – ceth Dec 13 '11 at 13:26
1

It idepends.... You must write queries and compare the execution plans to get the answer.

ceth
  • 44,198
  • 62
  • 180
  • 289