I am writing my join query by the following 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
AND t1.County_Id = t2.CountyId
AND t1.Group_code = t2.Doc_type_group_code
However it can also be written this way as well
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 p开发者_开发百科referred way to code.
That's an age-old argument - whether to specify additional WHERE arguments in the JOIN clause or as a separate WHERE.
I prefer the approach of defining only those arguments that really make up the JOIN inside the JOIN clause, and everything else later on in the WHERE clause. Seems cleaner to me.
But I think in the end, functionally, it's the same - it's just a matter of personal preference, really.
Both queries will have the same result and your sql-server should handle both in the same way. So there is no difference at all - just how you want to do it. You even can do it the following way:
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
精彩评论