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

MySQL批量替换指定字段字符串语句

 

UPDATE 表名 SET 字段名= REPLACE( 替换前的字段值, '替换前关键字', '替换后关键字' ) WHERE 字段名 REGEXP "替换前的字段值"; 

UPDATE user SET mobile= REPLACE( head_img, "http://7xswdm.com1.z0.glb.clouddn.com", "http://qiniu-img.popoyoo.com" );


(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;
 
UPDATE `ff_vod` SET  vod_url=REPLACE(vod_url,'https://','播放$https://') WHERE `vod_cid` = 41

修改类型 48 改成 39

 Update ff4_vod Set vod_cid = 39  Where vod_cid = 48

相关推荐

网友评论(0)