0
如果有人能夠解釋下面的代碼如何在內部工作,我將不勝感激。例如,如何評估條件順序。SQL更新查詢說明
update br set ScannedId =
(
select top 1 Id from table1 sp (nolock)
inner loop join table2 cp (nolock) ON (sp.CPId = cp.CPID)
inner loop join table3 c (nolock) ON (cp.CID = c.CId and c.endDate >= sp.CreatedDate and c.startDate <= sp.CreatedDate) `enter code here`
inner loop join table4 cc (nolock) ON (c.CChannelID =`enter code here` cc.CChannelID)
where (sp.UserId is null or sp.UserId = br.UserId)
and ((sp.Email = br.UserEmail)
or (sp.fName like br.UFName + '%' and sp.LName like br.ULName + '%' and sp.sHash = br.uHash)
or (sp.fName like br.UFName + '%' and sp.Addrs = br.UOAddrs and sp.ZC = br.UOZ and sp.sHash = br.uHash))
order by cc.Rank, c.Rank, cp.Rank, sp.EDate desc, sp.CreatedDate desc
)
from channelnewlogic br where userId = 3637217
possible dupe https://stackoverflow.com/questions/30749913/which-performs-first-where-clause-or-join-clause – gordy