0

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.

Mark Sinkinson
10.7k4 gold badges47 silver badges54 bronze badges
asked Jan 14, 2015 at 13:24

1 Answer 1

1

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.

Aaron Bertrand
182k28 gold badges407 silver badges626 bronze badges
answered Jan 14, 2015 at 13:34
1
  • 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. Commented Jan 14, 2015 at 16:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.