LEFT JOINs and order of positions of fields in ON condition

Database

LEFT JOINs and order of positions of fields in ON condition

Normally when I build a query with LEFT JOINs I have a previously mentioned table on the left side of the equal the table in the LEFT JOIN on the right side of it. In analyzing queries that a 3rd party app is executing I see something like the following:

SELECT *

FROM S1.TABLE_A ID

LEFT JOIN S1.TABLE_B B on B.ID=A.ID 

I would've written it as 

SELECT *

FROM S1.TABLE_A ID

LEFT JOIN S1.TABLE_B B on A.ID=B.ID 

When I look at the EXPLAINS for both I get the same result and time to execute. I think when it's executing this way it's the equivalent of an INNER join. Is there any benefit to getting the first query 'corrected' to be the 2nd query? Also, the actual table contain millions of records... and in some cases billions.

Thanks.

Tags (2)
1 REPLY
Teradata Employee

Re: LEFT JOINs and order of positions of fields in ON condition

The order of the expressions in an equality makes no difference of any kind. It definately does not turn this query into an inner join. The two queries above are identical from the point of view of the database and per the SQL standard as well.