T-SQL基本的更新语句(修改语句)

--Update基本语法
--update 表名 set 字段='修改的内容',字段='修改的内容' where 字段='内容'
--可以单个字段,也可以多个字段 多个字段要以  ,(逗号)隔开
update userinfo set userName='adadf',UserPass='wewe' where ID=5

--update 表名 set 字段='内容'
--注意:这样会把整个表的字段修改
update userinfo set userName='adadf'

--update 表名 set 字段=字段+'追加内容' where 字段='内容'
update userinfo set userName=userName+'adadf' where ID=5

--update 表名 set 字段='修改内容' where 字段='内容' or id<6
--字段=内容  或者id<6的 修改
update userinfo set userName='adadf' where Email='lqwvje@163.com' or ID<6

--update 表名 set 字段='修改内容' where 字段='内容' or id<6
--字段=内容  并且id<6的 修改
update userinfo set userName='adadf' where Email='lqwvje@163.com' and ID<6

--update 表名 set 字段=replace(字段, '罗','明')
--把字段中所有的‘罗’都换成‘明’