SQL Server Update 链接修改和when的应用
一、自链接方式
update b1 set b1.money = b1.money + b2.money from (select * from wallet where type='余额') b1 inner join (select * from wallet where type='积分') b2 on b1.userId= b2.userId
二、表链接
update r set r.cEnable = 0 from 表1 r inner join 表2 t on t.cId = r.cId where r.cRow = 100
三、When 在update 中的应用
update wallet set money = case type when 0 then money - 100 when 1 then money - 200 else money - 50 end where money > 1000
或
update wallet set money = case when money > 1000 and money < 1500 then money - 300 when money > 1500 and money < 2500 then money - 500 else money - 100 end where money > 1000