求一条sql的update语句??

来源:百度知道 编辑:UC知道 时间:2024/06/16 17:22:56
一个表有两个字段,id ( 自增),name
如:1 A
2 B
3 C
4 D
5 E
...
...
10 M
...
...
15 Z
用一条sql语句,把前1--5条的name 改成A ,6--10条改成B,11--15条改成C。

谢谢。

update cai set name= (case when (id>=1 and id<=5) then 'A' when (id>=6 and id<=10) then 'B' else 'C' end)
where id >=1 and id<=15

--MS_SQL

set rowcount 130;--限制更新130条记录,26个字母*5条记录一个字母
update 表名
set Name=char((ID-1)/5+65)
set rowcount 0;

update biao set name = (case when id>=1 and id<=5 then 'A'
when id>=6 and id<=10 then 'B'
else 'C'
End)