UPDATE

改(UPDATE)

1.更新特定值。

2.根据表中某列来更新。

3.跨表更新

select  *  from new.dbo.消费
update new.dbo.消费 set 日期 = '2019-03-12'      --更新特定值
select  *  from new.dbo.消费
update new.dbo.消费 set 日期 = 更新时间 +1        --根据某一列更新
select  *  from new.dbo.消费


--跨表更新
--方法一
select * from new.dbo.city  
update new.dbo.消费 set 城市 = city.城市 from city  where 消费.数值 = city.数值 
select  *  from new.dbo.消费       --如果city中没有对应的数值则不更新,比如郑州。
--方法二
update new.dbo.city set 数值 = 数值 + 1
update t1 set t1.数值 = t2.数值 from new.dbo.消费 AS T1,city as T2  where T1.城市  = T2.城市  
select  *  from new.dbo.消费 

原文地址:https://www.cnblogs.com/qianslup/p/10976709.html