MySQL中的substr()函数
创始人
2025-01-16 18:35:10
0

截取函数substr()方法以及参数详解

1、substr(str, position)   从position截取到字符串末尾

str可以是字符串、函数、SQL查询语句

position代表起始位置,索引位置从1开始

select substr(now(), 6); select substr('2023-10-25', 6); select substr((select fieldName from tableName where condition), 1);

2、substr(str from position)  从position截取到字符串末尾

和1的操作类似,和上面1的操作对比可以发现只是把括号中的逗号换成from关键字

select substr(now() from 6); select substr('2023-10-25' from 6); select substr((select fieldName from tableName where condition) from 1); 

3、substr(str, position, length)  从position截取长度为length的字符串

str可以是字符串、函数、SQL查询语句

position代表起始位置

length代表截取的字符串长度

select substr(now(), 1, 4); select substr('2024-01-01', 1, 4); select substr((select fieldName from tableName where condition), 1, 4);

4、substr(str from position for length)  从position截取长度为length的字符串

和3的操作类似,和上面3的操作对比可以发现只是把括号中的第一个逗号换成from关键字,

第二个逗号换成了for关键字

select substr(now() from 6 for 5); select substr('2023-10-01' from 6 for 5); select substr((select fieldName from tableName where condition) from 6 for 5);

相关内容

热门资讯

透视脚本!WePOker有没有... 透视脚本!WePOker有没有透视方法,wepoker私人局俱乐部怎么进,秘籍教程(一直是有挂)-哔...
据公告内容!盛世透视辅助器,衢... 据公告内容!盛世透视辅助器,衢州都莱有没有挂,攻略方法(切实是有挂)-哔哩哔哩1、任何衢州都莱有没有...
透视代打ai!拱趴大菠萝自动计... 透视代打ai!拱趴大菠萝自动计算机器人(透视)开挂辅助技巧(一直是有挂)-哔哩哔哩1、拱趴大菠萝自动...
透视透视挂!hhpoker智能... 透视透视挂!hhpoker智能辅助插件,德普之星怎么设置埋牌,机巧教程(好像是真的挂)-哔哩哔哩1、...
透视胜率!epoker透视(透... 透视胜率!epoker透视(透视)开挂辅助软件(竟然存在有挂)-哔哩哔哩;1、操作简单,无需注册,只...
一直以来!微信小程序游戏辅助,... 一直以来!微信小程序游戏辅助,兴动互娱辅助工具名称,大神讲解(确实真的有挂)-哔哩哔哩1、完成兴动互...
透视能赢!pokerworld... 透视能赢!pokerworld修改器,wepoker数据分析工具,操作教程(都是有挂)-哔哩哔哩1、...
透视自建房!hhpoker德州... 透视自建房!hhpoker德州有挂吗(透视)开挂辅助软件(真是是有挂)-哔哩哔哩一、hhpoker德...
为了进一步!微信小程序挂后台,... 为了进一步!微信小程序挂后台,填的那款辅助视频,揭秘教程(其实是真的挂)-哔哩哔哩1、填的那款辅助视...
透视新版!pokemmo免费脚... 透视新版!pokemmo免费脚本,智星德州可以透视吗,资料教程(都是真的是有挂)-哔哩哔哩1、智星德...