sql update求助

来源:百度知道 编辑:UC知道 时间:2024/05/18 07:02:07
有这样一个表
sort_id1 sort_id2 code name
01 01 0101 *
01 01 0102 *
02 02 0201 *
02 02 0202 *
依次类推,现在我想把01类的code改成0501,0502,而05类的code改成0801,0802,这个该怎么改,请大侠们赐教
我知道一条一条写,但是那样数量太多了,有没有不用一条一条写的呢

set code='05'+substring(code,3,2) where sort_id1='01'
这个我不懂意思。

一条一条写
update 表名 set code='0501' where sort_id1='01'

.
.
.
.
.
.

或者建个临时表,里边的字段分别是sort_id1,code

然后两个表关联去update

update 表名 set code='05'+substring(code,3,2) where sort_id1='01'
因为你修改的东西的规律很少,所以也只能慢慢改了

似乎也没有什么好办法
给你答问题的这些时间估计已经可以完成了
你写好一句,复制黏贴几下就可以了
其实也很快