0

Possible Duplicate:
Explicit vs implicit SQL joins

First:

SELECT a.field, b.field
FROM a, b
WHERE a.id = b.id

Second:

SELECT a.field, b.field
FROM a INNER JOIN b
ON a.id = b.id

Are there any differences between these two approaches or they work the same way?

Community
  • 1
  • 1
Marlon Vidal
  • 669
  • 4
  • 14
  • 1
    The final result will be the same. The question is if the execution will be the same. I guess that for this simple query the planner will be smart enough to make the same plan for both. – Clodoaldo Neto Sep 27 '12 at 17:06
  • read the link that rs. posted – Gonzalo.- Sep 27 '12 at 17:11
  • 1
    No difference except the possibility for errors and the difficulty in maintenance. Please read: https://sqlblog.org/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins.aspx – Aaron Bertrand Sep 27 '12 at 17:11
  • i've searched something like this, but i failed in the used keywords :( anyway thanks for the post, i'll take a look right now – Marlon Vidal Sep 27 '12 at 17:52

1 Answers1

0

They yield the same results and perform the same, but I find the second method is far more legible in large queries, so it should always be used (although I format it differently)

I format like this:

SELECT
    a.field
   ,b.field
FROM a
INNER JOIN b ON a.id = b.id
UnhandledExcepSean
  • 12,504
  • 2
  • 35
  • 51