mysql-批量修改表字段中的某一部分内容

MySQL批量替换指定字段字符串语句
(1)updat 表名 set 字段名=replac(字段名,'原来的内容','替换后的内容')
  举一个例子,就是我实际操作的时候的命令:

  update cpg1410_pictures set filepath=replac(filepath,'wallpapers/art/','wallpapers/beautiful/art/')
  或者
  update xb_upload_1 set fileurl=replac(fileurl,'www.baidu.com/','baidu.com/')

 

 


(2)updat 数据表名 SET 字段名 = replac(字段名, '要替换的字符串', '替换为') wher 设定条件;
  语句中还可以加入替换条件,如只替换限定ID小于200的内容:

  update wp_posts SET post_content = replac(post_content, '搜索引擎优化', '搜索引擎营销') wher ID < 200;

 

posted @ 2016-06-29 14:28  243573295  阅读(21491)  评论(0编辑  收藏  举报