将更新语句合并为一个

时间:2019-01-16 16:50:35

标签: sql sql-server

我有以下用于7个状态的更新语句示例,什么是将所有内容合并到一个更新语句中的最佳方法。

update tt
set tax = 'il'
from tax_table tt 
inner join name n on tt.id = n.id
 where states = 'il' 

update tt
set tax = 'md'
from tax_table tt 
inner join name n on tt.id = n.id
where states = 'md'

谢谢

1 个答案:

答案 0 :(得分:3)

update tt
set tax = states
from tax_table tt 
inner join name n on tt.id = n.id
where states IN ('tt', 'md')