首页 热点专区 义务教育 高等教育 出国留学 考研考公

修改mysql数据库的字符串替换

发布网友 发布时间:2022-04-22 01:15

我来回答

2个回答

热心网友 时间:2022-04-07 15:57

您好,update mt2 set name = replace(name, substring(name, locate('<contact>', name),locate('</contact>', name)-locate('<contact>'+10, name)),'');
locate:
LOCATE(substr,str)
POSITION(substr IN str)
返回子串 substr 在字符串 str 中第一次出现的位置。如果子串 substr 在 str 中不存在,返回值为 0:
substring
SUBSTR(str,pos,len): 由<str>中的第<pos>位置开始,选出接下去的<len>个字元。
replace
replace(str1, str2, str3): 在字串 str1 中,当 str2 出现时,将其以 str3 替代。

热心网友 时间:2022-04-07 17:15

update table1 set B=concat('我是',A,'非常棒的') where id <55

基本如上,但是要确保B字段长度足够长,另外,update前,请提前备份table1表,避免出错。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com