<p>Is there any efficiency difference in an explicit vs implicit inner join?
For example:</p>

<pre><code>SELECT * FROM
table a INNER JOIN table b
ON a.id = b.id;
</code></pre>

<p>vs.</p>

<pre><code>SELECT a.*, b.*
FROM table a, table b
WHERE a.id = b.id;
</code></pre>

[{'answer_id': 44932, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 8, 'selected': True, 'text': '<p>Performance wise, they are exactly the same (at least in SQL Server).</p>\n\n<p>PS: Be aware that the <code>IMPLICIT OUTER JOIN</code> syntax is deprecated since SQL Server 2005. (The <code>IMPLICIT INNER JOIN</code> syntax as used in the question is still supported)</p>\n\n<p><a href="https://learn.microsoft.com/en-us/archive/blogs/wardpond/deprecation-of-old-style-join-syntax-only-a-partial-thing" rel="noreferrer">Deprecation of "Old Style" JOIN Syntax: Only A Partial Thing</a></p>\n'}, {'answer_id': 44958, 'author': 'grom', 'author_id': 486, 'author_profile': 'https://Stackoverflow.com/users/486', 'pm_score': 7, 'selected': False, 'text': '<p>Personally I prefer the join syntax as its makes it clearer that the tables are joined and how they are joined. Try compare larger SQL queries where you selecting from 8 different tables and you have lots of filtering in the where. By using join syntax you separate out the parts where the tables are joined, to the part where you are filtering the rows.</p>\n'}, {'answer_id': 44977, 'author': 'Joshdan', 'author_id': 1990, 'author_profile': 'https://Stackoverflow.com/users/1990', 'pm_score': 3, 'selected': False, 'text': '<blockquote>\n  <p>Performance wise, they are exactly the same (at least in SQL Server) but be aware that they are deprecating this join syntax and it\'s not supported by sql server2005 out of the box.</p>\n</blockquote>\n\n<p>I think you are thinking of the deprecated *= and =* operators vs. "outer join".</p>\n\n<p>I have just now tested the two formats given, and they work properly on a SQL Server 2008 database.  In my case they yielded identical execution plans, but I couldn\'t confidently say that this would always be true.</p>\n'}, {'answer_id': 44981, 'author': 'Leigh Caldwell', 'author_id': 3267, 'author_profile': 'https://Stackoverflow.com/users/3267', 'pm_score': 2, 'selected': False, 'text': "<p>On some databases (notably Oracle) the order of the joins can make a huge difference to query performance (if there are more than two tables). On one application, we had literally two orders of magnitude difference in some cases. Using the inner join syntax gives you control over this - if you use the right hints syntax.</p>\n\n<p>You didn't specify which database you're using, but probability suggests SQL Server or MySQL where there it makes no real difference.</p>\n"}, {'answer_id': 44982, 'author': 'deadbug', 'author_id': 4646, 'author_profile': 'https://Stackoverflow.com/users/4646', 'pm_score': 3, 'selected': False, 'text': "<p>@lomaxx:  Just to clarify, I'm pretty certain that both above syntax are supported by SQL Serv 2005.  The syntax below is NOT supported however</p>\n\n<pre><code>select a.*, b.*  \nfrom table a, table b  \nwhere a.id *= b.id;\n</code></pre>\n\n<p>Specifically, the outer join (*=) is not supported.</p>\n"}, {'answer_id': 48280, 'author': 'andy47', 'author_id': 2661, 'author_profile': 'https://Stackoverflow.com/users/2661', 'pm_score': 4, 'selected': False, 'text': '<p>The first answer you gave uses what is known as ANSI join syntax, the other is valid and will work in any relational database.</p>\n\n<p>I agree with grom that you should use ANSI join syntax. As they said, the main reason is for clarity. Rather than having a where clause with lots of predicates, some of which join tables and others restricting the rows returned with the ANSI join syntax you are making it blindingly clear which conditions are being used to join your tables and which are being used to restrict the results.</p>\n'}, {'answer_id': 85745, 'author': 'Mike McAllister', 'author_id': 16247, 'author_profile': 'https://Stackoverflow.com/users/16247', 'pm_score': 2, 'selected': False, 'text': '<p>As Leigh Caldwell has stated, the query optimizer can produce different query plans based on what functionally looks like the same SQL statement. For further reading on this, have a look at the following two blog postings:-</p>\n\n<p><a href="http://optimizermagic.blogspot.com/2007/12/outerjoins-in-oracle.html" rel="nofollow noreferrer">One posting from the Oracle Optimizer Team</a></p>\n\n<p><a href="http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/" rel="nofollow noreferrer">Another posting from the "Structured Data" blog</a></p>\n\n<p>I hope you find this interesting.</p>\n'}, {'answer_id': 317465, 'author': 'edosoft', 'author_id': 6399, 'author_profile': 'https://Stackoverflow.com/users/6399', 'pm_score': 6, 'selected': False, 'text': '<p>The second syntax has the unwanted possibility of a cross join: you can add tables to the FROM part without corresponding WHERE clause. This is considered harmful.</p>\n'}, {'answer_id': 8331006, 'author': 'David', 'author_id': 1074000, 'author_profile': 'https://Stackoverflow.com/users/1074000', 'pm_score': 1, 'selected': False, 'text': '<p>Performance wise, it should not make any difference. The explicit join syntax seems cleaner to me as it clearly defines relationships between tables in the from clause and does not clutter up the where clause.</p>\n'}, {'answer_id': 10308304, 'author': 'Matt Fenwick', 'author_id': 894284, 'author_profile': 'https://Stackoverflow.com/users/894284', 'pm_score': 6, 'selected': False, 'text': "<p>On MySQL 5.1.51, both queries have identical execution plans:</p>\n\n<pre><code>mysql&gt; explain select * from table1 a inner join table2 b on a.pid = b.pid;\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n| id | select_type | table | type | possible_keys | key  | key_len | ref          | rows | Extra |\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n|  1 | SIMPLE      | b     | ALL  | PRIMARY       | NULL | NULL    | NULL         |  986 |       |\n|  1 | SIMPLE      | a     | ref  | pid           | pid  | 4       | schema.b.pid |   70 |       |\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n2 rows in set (0.02 sec)\n\nmysql&gt; explain select * from table1 a, table2 b where a.pid = b.pid;\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n| id | select_type | table | type | possible_keys | key  | key_len | ref          | rows | Extra |\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n|  1 | SIMPLE      | b     | ALL  | PRIMARY       | NULL | NULL    | NULL         |  986 |       |\n|  1 | SIMPLE      | a     | ref  | pid           | pid  | 4       | schema.b.pid |   70 |       |\n+----+-------------+-------+------+---------------+------+---------+--------------+------+-------+\n2 rows in set (0.00 sec)\n</code></pre>\n\n<p><code>table1</code> has 166208 rows; <code>table2</code> has about 1000 rows.</p>\n\n<p>This is a very simple case; it doesn't by any means prove that the query optimizer wouldn't get confused and generate different plans in a more complicated case.</p>\n"}, {'answer_id': 31995500, 'author': 'Sean', 'author_id': 5224741, 'author_profile': 'https://Stackoverflow.com/users/5224741', 'pm_score': -1, 'selected': False, 'text': '<p>In my experience, using the cross-join-with-a-where-clause syntax often produces a brain damaged execution plan, especially if you are using a Microsoft SQL product.  The way that SQL Server attempts to estimate table row counts, for instance, is savagely horrible.  Using the inner join syntax gives you some control over how the query is executed.  So from a practical point of view, given the atavistic nature of current database technology, you have to go with the inner join.</p>\n'}, {'answer_id': 55950981, 'author': 'Michele La Ferla', 'author_id': 1116216, 'author_profile': 'https://Stackoverflow.com/users/1116216', 'pm_score': 2, 'selected': False, 'text': "<p>Basically, the difference between the two is that one is written in the old way, while the other is written in the modern way. Personally, I prefer the modern script using the inner, left, outer, right definitions because they are more explanatory and makes the code more readable.</p>\n\n<p>When dealing with inner joins there is no real difference in readability neither, however, it may get complicated when dealing with left and right joins as in the older method you would get something like this:</p>\n\n<pre><code>SELECT * \nFROM table a, table b\nWHERE a.id = b.id (+);\n</code></pre>\n\n<p>The above is the old way how a left join is written as opposed to the following:</p>\n\n<pre><code>SELECT * \nFROM table a \nLEFT JOIN table b ON a.id = b.id;\n</code></pre>\n\n<p>As you can visually see, the modern way of how the script is written makes the query more readable. (By the way same goes for right joins and a little more complicated for outer joins).</p>\n\n<p>Going back to the boiler plate, it doesn't make a difference to the SQL compiler how the query is written as it handles them in the same way. I've seen a mix of both in Oracle databases which have had many people writing into it, both elder and younger ones. Again, it boils down to how readable the script is and the team you are developing with.</p>\n"}]
['https://Stackoverflow.com/questions/44917', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4316/']