Testing some commands of MySQL, I've come across these two comands resulting on the same table.

Command 1:

select sales.relatory_code, sales.date, destiny.exportation_name from sales, destiny where sales.destiny_exportation_code = destiny.destiny_exportation_code;

Command 2:

select sales.relatory_code, sales.date, destiny.exportation_name from sales inner join destiny on sales.destiny_exportation_code = destiny.destiny_exportation_code;

Basically, instead of using two tables on "from" clause and using the "where" clause, i'm just using "inner join". I would like to know what's the main difference between the two commands and if one is better than the other.

up vote 1 down vote accepted

Command 1 is the SQL-89 standard for joining between tables.

Command 2 is the correct method of writing JOINs as per the ANSI-92 SQL standard (yes, that is 92 as in 1992). Some 23 years later and people still don't want to conform to ANSI-join standards.

Theoretically, there is no difference between the two in terms of performance, it's apparently just a hard habit for people to break and some find it more readable if they're used to writing queries in that way.

There's a few more reasons for why people use the old standard as opposed to the new one in this Stack Overflow post.

I also seemingly keep referring back to Aaron Bertrand's posts (even though this one is written about SQL Server). This one may give you some more information on why you should be using the ANSI-92 Standard style joins.

  • oh, i get it now. thank you so much – tinyeyes Jan 14 '15 at 13:52
  • I totally agree that it's better to use the new style (and certainly don't mix the two) but the old-style is still valid SQL, according to the SQL-92 standard. Even according to SQL-2011 standard. It's not wrong per se. – ypercubeᵀᴹ Jan 14 '15 at 16:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.