当前位置:网站首页>How does MySQL control the number of replace?
How does MySQL control the number of replace?
2022-07-07 13:51:00 【Full stack programmer webmaster】
I want to put “ABC yes ABC” Replace with “123 yes ABC”, That is to find the first one ABC Replace with 123,MYSQL How the order should be written ?
UPDATE data SET body=REPLACE(body, ‘ABC’, ‘123’); When I use this command, I will put all ABC Are replaced with 123, I don't know how to control the number of replacements , Ask an expert for advice .
hemu780924 Brother's code can be used , But there is a fatal flaw ,
such as "123 yes ABC", If you want to find XYZ And replace it with OPQ, Because in "123 yes ABC" Can't find XYZ, Then the order will be "123 yes ABC" Insert in front XYZ, This is not what I want !
update table1 set body =
concat(
SUBSTRING(body ,1,position('ABC' in body )-1),
'123',
substring(body ,position('ABC' in body )+length('ABC'))) where body like '%ABC%'
Here replace the first ABC , No, ABC No replacement
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113283.html Link to the original text :https://javaforall.cn
边栏推荐
- mysql 局域网内访问不到的问题
- Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
- FCOS3D label assignment
- 2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
- 最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
- move base参数解析及经验总结
- 干货|总结那些漏洞工具的联动使用
- Cinnamon taskbar speed
- The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
- LeetCode简单题分享(20)
猜你喜欢
566. Reshaping the matrix
10 pictures open the door of CPU cache consistency
Dry goods | summarize the linkage use of those vulnerability tools
提升树莓派性能的方法
Navicat run SQL file import data incomplete or import failed
Ogre introduction
Leetcode simple question sharing (20)
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
Help tenants
2022-7-6 Leetcode27.移除元素——太久没有做题了,为双指针如此狼狈的一天
随机推荐
[1] Basic knowledge of ros2 - summary version of operation commands
Mysql怎样控制replace替换的次数?
Final review notes of single chip microcomputer principle
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
PHP中用下划线开头的变量含义
10 pictures open the door of CPU cache consistency
Huawei image address
2022-7-6 Leetcode 977. Square of ordered array
Help tenants
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
参数关键字Final,Flags,Internal,映射关键字Internal
3D Detection: 3D Box和点云 快速可视化
1、深拷贝 2、call apply bind 3、for of for in 区别
566. 重塑矩阵
call undefined function openssl_cipher_iv_length
作战图鉴:12大场景详述容器安全建设要求
Introduction and basic use of stored procedures
干货|总结那些漏洞工具的联动使用
LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement