当前位置:网站首页>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
边栏推荐
- 现在网上开户安全么?那么网上开户选哪个证券公司?
- Esp32 ① compilation environment
- C语言数组相关问题深度理解
- Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
- Redis只能做缓存?太out了!
- Mongodb replication (replica set) summary
- ESP32 ① 编译环境
- LeetCode简单题分享(20)
- mysql 局域网内访问不到的问题
- 实现IP地址归属地显示功能、号码归属地查询
猜你喜欢
Write it down once Net a new energy system thread surge analysis
Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
Milkdown control icon
Getting started with cinnamon applet
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
为租客提供帮助
Leetcode simple question sharing (20)
Dry goods | summarize the linkage use of those vulnerability tools
高等數學---第八章多元函數微分學1
随机推荐
ROS机器人更换新雷达需要重新配置哪些参数
[QNX Hypervisor 2.2用户手册]6.3.4 虚拟寄存器(guest_shm.h)
Milkdown control icon
Clion mingw64 Chinese garbled code
postgresql array类型,每一项拼接
Help tenants
Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
C语言数组相关问题深度理解
数字ic设计——SPI
PostgreSQL array type, each splice
move base参数解析及经验总结
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
我那“不好惹”的00后下属:不差钱,怼领导,抵制加班
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
QQ的药,腾讯的票
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
Detr introduction
如何让join跑得更快?
Excerpt from "misogyny: female disgust in Japan"
Signal strength (RSSI) knowledge sorting