根据where子句确定要更新的字段

时间:2019-04-15 15:32:14

标签: sql sql-server

我必须根据where条件更新一个表字段。

select ttc.*,
(case 

when ttc.TagId1=t.Id  then TagDescription1 
when ttc.TagId2 =t.id then TagDescription2 
when ttc.TagId3 =t.id then TagDescription3
when ttc.TagId4=t.id then TagDescription4 
end )  TagDescription from @tagIDTable temp
inner join Table1 T on temp.ID =t.Id 
left join Table2 TTC on TTC.TagId1 =t.Id 
or TTC.TagId2 =t.Id 
or TTC.TagId3 =t.Id 

上面是我写的选择语句。我必须更新tagdescription字段。我们有4个tagdescriptions。基于条件我需要更新它。如何以优化的方式进行更新

0 个答案:

没有答案
相关问题