惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - Hoooooo

华为交换机系统视图状态system-view超时设置 access trunk hybird untagged和tagged区别 WIN系统命令行添加防火墙配置 yum 安装包时解决依赖关系 Shell脚本--磁盘空间有超过80%时发信息 dos修改字符串排序,可用于修改文件名 linux系统调优用命令 centos7安装配置vnc和远程桌面,WIN10 mstsc远程linux gnome桌面 在linux系统中curlftpfs自动挂载ftp 文件抽取 win10 ie ActiveX 对应注册表编号 AUTUCAD2017 key 五种开源协议(BSD,Apache,GPL,LGPL,MIT) vim 编辑不显示以#或其它开始的行 mysql忘记root密码解决办法 Redhat 7及Centos 7系统网卡启动 mysql ROOT管理员密码修改 awk字符意义 redhat 7安装oracle 11gr2
mysql中字符查询与替换
Hoooooo · 2018-07-24 · via 博客园 - Hoooooo

select * from tablename where column like "%str%"----------------------查询表中的某列里包含某str的行

update ear_bbs_threads_content set content = replace(content, substring(content, locate('[url=', content),locate('[url=',content)-locate('[/url]', content)),'')----------替换content内容里面以[url=开始并以[/url]结束之间的所有字符

update tablename set column =replace(column,'str','')-------------------替换表中某列里内容为str的字符串

update table set content=left(content,locate('str',content)+1)-----------删除表中某列里str后的内容

select trim(leading 'x' from 'xxxadminxxx')-----------------------------------删除字符串xxxadminxxx前xxx

select trim(trailing 'x' from 'xxxadminxxx')---------------------------------- -删除字符串xxxadminxxx后xxx 

select trim(both 'x' from 'xxxadminxxx')---------------------------------------删除字符串xxxadminxxx前后的xxx

delete from `表` where `字段` not like '%指定字符1%'--------------------删除不包含某字符串的记录

delete from `表` where `字段` like '%指定字符1%' or like '%指定字符2%' or like '%指定字符3%'------------删除包含某字符串的记录

以下为mysql删除两字符间所有字符的测试过程,参考过程来源博客见最后备注:

update ear_bbs_threads_content set content = dbo.RegexReplace('<*>','',content,1,1);
update ear_bbs_threads_content set content =replace(content,'[url*url]','') where tid >=100 and tid <=1000
update ear_bbs_threads_content set content = replace(content, substring(content, locate('[url=', content),locate('[/url]', content)-locate('[url=',content)),'')
update ear_bbs_threads_content set content = replace(content, substring(content, locate('[url=', content),locate('[/url]', content))),'')

update ear_bbs_threads_content set content = replace(content, substring(content, locate('[url=', content),locate('[url=',content)-locate('[/url]', content)),'')

其过程详细说明为:

使用 SubString字符串截取函数
SubString(string, int, int)
返回第一个参数中从第二个参数指定的位置开始、第三个参数指定的长度的子字符串。
然后用update set即可达到删除字符串的前两个字符的效果
sql
update table set name= substring(name,3,len(name)-2);
解释:更新table表中name字段
substring(name,3,len(name)-2);表示返回从name字段的第三个字符之后的所有字符
效果就是删除前2个字符了
len(name)表示返回name字段的长度

参考地址为百度知道的:https://zhidao.baidu.com/question/588857422353045925.html