当前位置:网站首页>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
边栏推荐
- 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)
- LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
- Mongodb meets spark (for integration)
- Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
- Toraw and markraw
- Battle Atlas: 12 scenarios detailing the requirements for container safety construction
- ROS机器人更换新雷达需要重新配置哪些参数
- 单片机学习笔记之点亮led 灯
- 实现IP地址归属地显示功能、号码归属地查询
- Leetcode simple question sharing (20)
猜你喜欢

Milkdown control icon

Flink | 多流转换

How far can it go to adopt a cow by selling the concept to the market?

Storage principle inside mongodb

Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)

交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)

Getting started with cinnamon applet

TPG x AIDU | AI leading talent recruitment plan in progress!

Introduction and basic use of stored procedures

实现IP地址归属地显示功能、号码归属地查询
随机推荐
566. Reshaping the matrix
Vscade editor esp32 header file wavy line does not jump completely solved
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
Simple and easy-to-use code specification
PHP - laravel cache
【日常训练--腾讯精选50】231. 2 的幂
Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
cmake 学习使用笔记(一)
Ikvm of toolbox Net project new progress
MySQL error 28 and solution
566. 重塑矩阵
[1] ROS2基础知识-操作命令总结版
Data refresh of recyclerview
Split screen bug notes
一文读懂数仓中的pg_stat
干货|总结那些漏洞工具的联动使用
xshell连接服务器把密钥登陆改为密码登陆
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
Final review notes of single chip microcomputer principle
User management summary of mongodb