当前位置:网站首页>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
边栏推荐
- 嵌入式开发用到的一些工具
- Implementation and application of queue
- 122. Thread class thread method summary; Why is the thread start method start () not run ()?
- 【无标题】
- PHP 字符串与二进制相互转换
- Drive away bad emotions and stop worrying
- Niuke monthly race 22 tree sub chain
- IPv6 learning notes
- 那个程序员,被打了。
- Packetdrill script analysis guide
猜你喜欢
随机推荐
PHP 字符串与二进制相互转换
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
CSDN一站式云服务开放内测,诚邀新老用户来抢鲜
js作用域链与闭包
Problems caused by delete and delete[]
Wechat applet WebView prohibits page scrolling without affecting the implementation of overflow scrolling in the business
计网01-物理层
数据中台咋就从“小甜甜”变成了“牛夫人”?
Huawei accounts work together at multiple ends to create a better internet life
What is P in cap theory
Scratch big fish eat small fish Electronic Society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
Nacos service configuration and persistence configuration
js 使用toString 区分Object、Array
Win11账号被锁定无法登录怎么办?Win11账号被锁定无法登录
Clickhouse: Test on query speed of A-share minute data [Part 2]
SDN_ Simple summary
PR training notes
PHP string to binary conversion
闭包实现迭代器效果
SQL learning notes (03) -- data constraint relationship
![Problems caused by delete and delete[]](/img/d9/a1c3e5ce51ef1be366a973aa42d1f0.png)






