当前位置:网站首页>Mysql怎样控制replace替换的次数?
Mysql怎样控制replace替换的次数?
2022-07-07 11:47:00 【全栈程序员站长】
我想把“ABC是ABC”替换成“123是ABC”,也就是找出第一个ABC替换成123,MYSQL命令应该怎么写?
UPDATE data SET body=REPLACE(body, ‘ABC’, ‘123’);我用这个命令时会把所有ABC都替换成123,不知道怎么控制替换次数,请高人指教。
hemu780924大哥的代码虽然能用,但是有个致命的缺陷,
比如"123是ABC",如果想找出XYZ并替换成OPQ,因为在"123是ABC"找不到XYZ,然后命令就会在"123是ABC"前面插入XYZ,这个不是我想要的啊!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%'
这里替换第一次的ABC ,没有ABC就不替换了发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/113283.html原文链接:https://javaforall.cn
边栏推荐
- Leecode3. Longest substring without repeated characters
- Esp32 ① compilation environment
- clion mingw64中文乱码
- 作战图鉴:12大场景详述容器安全建设要求
- Supply chain supply and demand estimation - [time series]
- Simple and easy-to-use code specification
- 室内ROS机器人导航调试记录(膨胀半径的选取经验)
- MySQL error 28 and solution
- Oracle advanced (V) schema solution
- Redis只能做缓存?太out了!
猜你喜欢

Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)

2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers

Redis只能做缓存?太out了!

xshell连接服务器把密钥登陆改为密码登陆

Ogre introduction

Distributed transaction solution

为租客提供帮助

Evolution of customer service hotline of dewu

118. Yanghui triangle

Flink | multi stream conversion
随机推荐
Cmake learning and use notes (1)
SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
Evolution of customer service hotline of dewu
干货|总结那些漏洞工具的联动使用
MySQL error 28 and solution
What parameters need to be reconfigured to replace the new radar of ROS robot
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Solve the cache breakdown problem
OSI seven layer model
Server to server (S2S) event (adjust)
【黑马早报】华为辟谣“军师”陈春花;恒驰5预售价17.9万元;周杰伦新专辑MV 3小时播放量破亿;法华寺回应万元月薪招人...
Getting started with MySQL
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Storage principle inside mongodb
Clion mingw64 Chinese garbled code
1、深拷贝 2、call apply bind 3、for of for in 区别
[QNX Hypervisor 2.2用户手册]6.3.4 虚拟寄存器(guest_shm.h)
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
Build a secure and trusted computing platform based on Kunpeng's native security