请教各位老师:我有如下表table1结构及数据:
编号 姓名
370001 A
370002 B
370003 C
...... .编号前两为均为37,现在需要将编号前两位变成36,而后四位不变,该SQL语句该如何写?
update table1 set 编号=????
编号 姓名
370001 A
370002 B
370003 C
...... .编号前两为均为37,现在需要将编号前两位变成36,而后四位不变,该SQL语句该如何写?
update table1 set 编号=????
uodate table1 set 编号=‘36’+copy(adoquery1.fieldbyname('编号').asstring,1,2)where....
uodate table1 set 编号='36'||substr(编号,3,4);
这是在oracle中实现,sqlserver中字符串连接也是'||',应该也可以得.如果'编号'是数字类型,更好办:
uodate table1 set 编号=编号-10000;
update table1 set 编号=replace(编号,'37','36')
370001 A
370002 B
370003 C
...... .编号前两为均为37,现在需要将编号前两位变成36,而后四位不变,该SQL语句该如何写?
update table1 set 编号=????
**********************************************update table1 set 编号 = '36' + right(编号,4)
或
update table1 set 编号 = '36'+right(编号,len(编号,-2))