当前位置:网站首页>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
边栏推荐
- 睡了二哥。。。
- 121. thread scheduling: join() method and yield() method
- UE small knowledge point controller possess pawn process
- Postgraduate entrance examination vocabulary 2023 sharing (1)
- 利用闭包实现私有变量
- ES6 decoupling top-level objects from windows
- js valueOf 与 toString 区别
- A 419 error occurred in the laravel postman submission form. July 6th, 2020 diary.
- The "China Mobile Chain" state secret engine was officially launched on BSN
- CSDN一站式云服务开放内测,诚邀新老用户来抢鲜
猜你喜欢

JS原型链

Packetdrill script analysis guide

The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious

我喜欢两个男人。。。

炒币,亏了1000万。

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

历史上的今天:九十年代末的半导体大战;冯·诺依曼发表第一份草案;CBS 收购 CNET...

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

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

Implementation and application of queue
随机推荐
Exception handling of classes in C #
SQL学习笔记(03)——数据约束关系
主流实时流处理计算框架Flink初体验
Mikrotik Routeros Internet access settings
架构实战营 毕业总结
js函数arguments对象
The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
我喜欢两个男人。。。
谁拥有穿越周期的眼光?
ESP8266 FreeRTOS开发环境搭建
SQL 化是 ETL 增量生产的第一步,这样的架构的核心能力是什么?
Project procurement management
node. How to implement the SQL statement after JS connects to the database?
js原型继承仅可继承实例而非构造器
The stock position building rate of global funds and asset management reached a new low in 15 years
SQL learning notes (02) - database table operation
SQL学习笔记(01)——数据库基本知识
硬件中台项目
京东与腾讯续签三年战略合作协议;起薪涨至26万元!韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条...
SDN_ Simple summary