zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

Mysql中如何批量替换某个字段的值:replace

mysql批量 如何 字段 替换 某个 replace
2023-06-13 09:19:58 时间

mxd_goods 中字段goods_pic的值要全部去掉goods/

现在要将该表中的所有goods_pic字段的值去掉goods/。

那么我们怎么来做呢?

update  mxd_goods set goods_pic= replace(goods_pic, goods/ , );

注:goods_pic是表字段值,goods/ 是被替换的值,即搜索的值, 是替换后的值,此处替换为空 

意思是去掉了goods/。一定要加where id =数字 ,否则将是全表修改哦。

怎么撤销呢?

update mxd_goods set goods_pic= replace(goods_pic, g_ , goods/g_ ) where goods_id=1849;

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

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 

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。


我想要获取技术服务或软件
服务范围:MySQL、ORACLE、SQLSERVER、MongoDB、PostgreSQL 、程序问题
服务方式:远程服务、电话支持、现场服务,沟通指定方式服务
技术标签:数据恢复、安装配置、数据迁移、集群容灾、异常处理、其它问题

本站部分文章参考或来源于网络,如有侵权请联系站长。
数据库远程运维 Mysql中如何批量替换某个字段的值:replace