表table
字段column
我有10条记录,column里都是01前缀,如010203,010205,0106
要求 将前缀改为02
update怎么写?

解决方案 »

  1.   

    update table set column="02"||substring(column,2) where column like '01%'
      

  2.   

    update tablename set column='02'+substr(column,3);
      

  3.   

    要看具体是什么数据库,使用相关的数据库提供的函数即可如果是SQL Server 就是update table set column='02'+substr(2)
      

  4.   

    同时,你也可以用procedure来写,执行一下就行了
      

  5.   

    有可能的话,写个JDBC的程序,把你的记录先读取出来,修改后再写回去,而不是直接去找SQL的语句怎么做。
      

  6.   

    select left(column,2) from table 是不是这样是取得column字段的前2个字符?我没有试验
      

  7.   

     update 表名 set  (select  substr(字段,1,2)   from   表名)=02