当前位置:网站首页>mysql截取_mysql截取字符串的方法[通俗易懂]
mysql截取_mysql截取字符串的方法[通俗易懂]
2022-07-01 09:41:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
1、从左开始截取字符串
left(str, length)
说明:left(被截取字段,截取长度)
例:select left(content,200) as abstract from my_content_t
2、从右开始截取字符串
right(str, length)
说明:right(被截取字段,截取长度)
例:select right(content,200) as abstract from my_content_t
3、截取字符串
substring(str, pos)
substring(str, pos, length)
说明:substring(被截取字段,从第几位开始截取)
substring(被截取字段,从第几位开始截取,截取长度)
例:select substring(content,5) as abstract from my_content_t
select substring(content,5,200) as abstract from my_content_t
(注:如果位数是负数 如-5 则是从后倒数位数,到字符串结束或截取的长度)
4、按关键字截取字符串
substring_index(str,delim,count)
说明:substring_index(被截取字段,关键字,关键字出现的次数)
例:select substring_index(”blog.chinabyte.com”,”。”,2) as abstract from my_content_t
结果:blog.chinabyte
(注:如果关键字出现的次数是负数 如-2 则是从后倒数,到字符串结束)
结果:chinabyte.com
截取的字符串为15,151,152,16’,可以看作是ip吧(虽然这里指的不是iP),
然后要截取每个逗号之前那部分
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/131770.html原文链接:https://javaforall.cn
边栏推荐
- 电脑USB、HDMI、DP各种接口及速度
- js 使用toString 区分Object、Array
- Hololens2 development -6-eyetracking and speech recognition
- Dotnet console uses microsoft Maui. Getting started with graphics and skia
- The "China Mobile Chain" state secret engine was officially launched on BSN
- SQL学习笔记(03)——数据约束关系
- BSN长话短说之十:如何保证NFT的安全
- PHP string to binary conversion
- 手指点击屏幕就模拟进入F11进入全屏
- What is P in cap theory
猜你喜欢
睡了二哥。。。
MapReduce programming basics
2022.02.15_ Daily question leetcode six hundred and ninety
苹果放大招!这件事干的太漂亮了……
好高的佣金,《新程序员》合伙人计划来袭,人人皆可参与!
华为帐号多端协同,打造美好互联生活
Huawei accounts work together at multiple ends to create a better internet life
How to realize the usage of connecting multiple databases in idel
JS原型链
The stock position building rate of global funds and asset management reached a new low in 15 years
随机推荐
PHP string to binary conversion
JS prototype chain
好高的佣金,《新程序员》合伙人计划来袭,人人皆可参与!
JS prototype inheritance can only inherit instances, not constructors
一个悄然崛起的国产软件,低调又强大!
PR training notes
Clickhouse: Test on query speed of A-share minute data [Part 2]
PHP 字符串与二进制相互转换
BSN long story 10: how to ensure the safety of NFT
闭包实现迭代器效果
Differences between JS valueof and toString
炒币,亏了1000万。
The "China Mobile Chain" state secret engine was officially launched on BSN
Tree structure -- binary tree 2 non recursive traversal
Exception handling of classes in C #
Network partition notes
A 419 error occurred in the laravel postman submission form. July 6th, 2020 diary.
Implementation and application of queue
Voice service notes
Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"