本教程操作环境:windows7系统、mysql8版本、dell g3电脑。
mysql字段全部替换以及字段部分替换
语法:
update 表名 set 字段名 = replace(字段名,'要替换的内容','替换成的内容');
也可以写成:
update 表名 set 字段名 = replace(字段名,fromstr,tostr);
(1)全部替换
全部替换就把被替换的和要替换送上去
update user_bag set cover_url = replace(cover_url, ‘http://static.zpnb.com/768.jpg’,‘http://static.bddvip.com/zpnb412.png’) where id = 1
(2)部分替换
比如我想把图片路径中的 http://static.zpnb.com/768.jpg ,http替换成https,只需要把http,和https填进去,顺序不要搞反。
update xxx set item_example_img = replace (item_example_img,‘http’,‘https’)
【相关推荐:mysql视频教程】
以上就是mysql怎么替换字段的详细内容。
