关于update更新表字段

第一种方法

update 表A  set  字段1=‘值’ where 条件限制
update T1 set wpmc='红笔' where wpmc='蓝笔'

第二种方法

update 表A  
set  字段1= (select ‘字段’ from 表B where 表B.对应字段2'=表A.对应字段2)  
where 条件限制
update T1 set wpmc=(select spmc from T2 where sptm=wpbm)  where isnull(wpmc,'')=''
--这里对应字段2'和对应字段2的名称要不一致

第三种方法

update 表A  set  字段1= 表B.‘字段值’)  
from 表A a left join 表B b on a.对应字段=b.对应字段 where 条件限制
update T1 set wpmc=spmc 
from T1 left join T2 on T1. wpbm=T2.sptm 
where isnull(wpmc,'')=''

你可能感兴趣的:(关于update更新表字段)