zoukankan      html  css  js  c++  java
  • 数据库修改某个字段的部分或全部内容

    1*.需求

    将表(Ws_FormMain)的字段(order_Number)内容为XSRK201706080001修改为WXSK201706080001

    update 表名 set 字段 = replace(字段, '要修改的内容' , '修改后的内容');

    UPDATE Ws_FormMain SET order_Number = REPLACE(order_Number, 'XSRK', 'WXSK') WHERE orderDefId = 513

    2*.需要修改sqlserver数据库中某一字段的值,例如从“1234560001”至“1234560999”的字段supplier_id进行修改,要求修改后的supplier_id字段值为“654321****”。

    可以使用replace()函数进行修改:update  table  set  supplier_id=replace(supplier_id,'123456','654321') where supplier_id like '123456%';

    replace()函数中,第一个参数表示的是需要进行操作的字段或值,第二个参数表示的需要被替换的字符串,第三个参数表示进行替换的字符串

    MYSQL中批量替换某个字段的部分数据:

    1.修改字段里的所有含有指定字符串的文字
    UPDATE 表A SET 字段B = replace(字段B, 'aaa', 'bbb')
        example: update  table set url= replace(url, 'aaa', 'bbb')  【将url字段中的aaa批量更改为bbb】
         update table  set url= REPLACE (url,'3','1.png')  where 条件;    
    2.常规条件修改:
    update table set column='' where column is null
    列:update  `table` set `url`='0' where `url` is null

    参考网址:https://blog.csdn.net/jiangnanqbey/article/details/81304834

           https://www.cnblogs.com/hao-1234-1234/p/10717864.html

           https://blog.csdn.net/qq_14997169/article/details/53241395

         https://blog.csdn.net/john320/article/details/16887967

  • 相关阅读:
    二 关键词关键词扩展(五)
    二 关键词关键词竞争程度判断(三)
    discuz X2.5 门户diy风格模版制作教程
    二 关键词关键词分布(六)
    seo各种跳转
    js 判断未定义
    网站运营赚钱的小心得
    二 关键词核心关键词(四)
    asp实现301跳转的方法
    UVA 11258 String Partition
  • 原文地址:https://www.cnblogs.com/jingzaixin/p/11978062.html
Copyright © 2011-2022 走看看