如何updatesql批量更新?
的有关信息介绍如下:
update 表名 set value=case when id=1 then 一个值 when id=2 then 一个值 when id=3 then 一个值 else value end 上边就是举个例子,意思是,当id=1时,把value设定个值,当id=2时,value设定另一个值,依次类推,不需要更改的保留原来的value值,最后以end结尾
用case语句试试: update Yao_Article set Author=(case Author when '山东 - 历下' then '/1/35/' when '山东 - 市中' then '/1/36/' ...... when '山东 - 济阳' then '/1/42/' else Author end) where Author like '山东 - %'
一楼正解,用case 但是要修正一下 update Yao_Article set Author=(case when Author='山东 - 历下' then '/1/35/' when '山东 - 市中' then '/1/36/' ...... when '山东 - 济阳' then '/1/42/' else Author end) where Author like '山东 - %'
declare v_num number(3); cursor cur_num is select id from table_name where id between 100 and 320; begin open cur_num; loop fetch cur_num into v_num; exit when cur_num%notfound; Update BD set IsActive = '0', comments = 'old BD 2001' where Id = v_num; commit; end loop; close cur_num; end;



