What the difference between the two below SQL Statements (one uses INNER JOIN, and the second uses the from clause) (Performance, execution time..),
and is there any cases i must use one instead of the other?
SELECT Tbl1_Fld1, Tbl2_Fld1 FROM DB1..TABLE1
INNER JOIN DB2..TABLE1
on DB1..TABLE1 .Tbl1_Fld1 = DB2..TABLE1.Tbl2_Fld1
SELECT Tbl1_Fld1, Tbl2_Fld1 FROM DB1..TABLE1,DB2..TABLE1
WHERE DB1..TABLE1 .Tbl1_Fld1 = DB2..TABLE1.Tbl2_Fld1
In a perfect world, those should be equivalent except that the first one better documents what you want to achieve (join two tables and then search the result).
Alas, history, bugs, features, optimizers and other obstacles make this much more complicated than it needs to be.
Some databases simply don’t support
INNER JOINeven though it’s a SQL standard syntax.Other have bugs for certain data types, so the join won’t work or will be very slow.
So in reality, you will have to run these with suitable test data to find out. There is no way to say for sure just by looking at the SQL. Sometimes, there isn’t even a way to say for sure when you can run it because changes in the underlying data can have a huge impact (for example, Oracle can suddenly decide to ignore the index because too many rows in the table have been changed).