批量更新SQL语句

来源:百度知道 编辑:UC知道 时间:2024/05/27 21:18:32
一个表有id,name字段,现在要求写一条SQL语句,更新id从1-10的name字段为A,11-20的name为B。请高人指教!

批量更新SQL语句
update qc_top set top_id='1' where id=1
update qc_top set top_id='1' where id=2

假如你的表为:T
update T
set name=
case when id>1 and id<10
then ‘A'
else ‘B’

update 表 set name=case when id>1 and id<10 then 'A' else 'B' end