What is the difference between these two queries?

I write my connection request as follows

UPDATE UPLOAD_TEMP SET UPLOAD_TEMP.Borr_Add_Req = t2.YesNoResponse, FROM UPLOAD_TEMP t1 INNER JOIN GB_RequiredFields t2 ON t1.State = t2.StateCode AND t1.County_Id = t2.CountyId AND t1.Group_code = t2.Doc_type_group_code 

However, it can also be written in the same way.

  UPDATE UPLOAD_TEMP SET UPLOAD_TEMP.Borr_Add_Req = t2.YesNoResponse, FROM UPLOAD_TEMP t1 INNER JOIN GB_RequiredFields t2 ON t1.State = t2.StateCode WHERE t1.County_Id = t2.CountyId AND t1.Group_code = t2.Doc_type_group_code 

Is there any difference between both and which is the preferred way of code.

+4
source share
2 answers

This is a century-old argument - specify optional WHERE arguments in the JOIN clause or as a separate WHERE clause.

I prefer the approach of only those arguments that really make up the JOIN inside the JOIN clause, and everything else is later in the WHERE clause. It seems to me that this is cleaner.

But I think that in the end, functionally, it's the same thing - it's just a matter of personal preference, really.

+4
source

Both queries will have the same result, and your sql server should process both methods the same way. So it makes no difference - just how you want to do it. You can even do it like this:

  UPDATE UPLOAD_TEMP SET UPLOAD_TEMP.Borr_Add_Req = t2.YesNoResponse, FROM UPLOAD_TEMP t1, GB_RequiredFields t2 WHERE t1.State = t2.StateCode AND t1.County_Id = t2.CountyId AND t1.Group_code = t2.Doc_type_group_code 
+1
source

All Articles