当前位置:网站首页>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
边栏推荐
- SQL learning notes (01) - basic knowledge of database
- js原型陷阱
- Matrix and coordinates
- Using closures to implement private variables
- 我喜欢两个男人。。。
- Tearful eyes, it's not easy to change jobs. Three rounds of interviews, four hours of soul torture
- 【leetcode】287. Find duplicates
- HMS core audio editing service 3D audio technology helps create an immersive auditory feast
- UE small knowledge point controller possess pawn process
- SQL学习笔记(04)——数据更新、查询操作
猜你喜欢

主流实时流处理计算框架Flink初体验

Flinkv1.13实现金融反诈骗案例

苹果放大招!这件事干的太漂亮了……

HMS core audio editing service 3D audio technology helps create an immersive auditory feast

好高的佣金,《新程序员》合伙人计划来袭,人人皆可参与!

Mikrotik Routeros Internet access settings

Who has the vision to cross the cycle?

Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"

云原生到底是什么?它会是未来发展的趋势吗?

嵌入式开发用到的一些工具
随机推荐
The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
js重写自己的函数
Computer USB, HDMI, DP various interfaces and speeds
SQL learning notes (01) - basic knowledge of database
Spark's action operator
Weidongshan board compilation kernel problem solving
What is P in cap theory
Differences between JS valueof and toString
CSDN's one-stop cloud service is open for internal testing, and new and old users are sincerely invited to grab the fresh
7-Zip boycotted? The callers have committed "three crimes": pseudo open source, unsafe, and the author is from Russia!
【leetcode】287. Find duplicates
node. How to implement the SQL statement after JS connects to the database?
ES6 const essence and completely immutable implementation (object.free)
Sd-wan notes
BSN长话短说之十:如何保证NFT的安全
SQL 化是 ETL 增量生产的第一步,这样的架构的核心能力是什么?
Get the list of a column in phpexcel get the letters of a column
Win11账号被锁定无法登录怎么办?Win11账号被锁定无法登录
Voice service notes
Dspic30f6014a LCD block display