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);

相关内容

热门资讯

透视妙计!德扑之心免费透视,德... 透视妙计!德扑之心免费透视,德普之星辅助工具如何设置(透视)都是真的有脚本方法(哔哩哔哩)1、很好的...
透视指引!hhpoker开挂教... 透视指引!hhpoker开挂教程,hh poker透视器下载(透视)总是是真的脚本器(哔哩哔哩)1、...
透视法门!悦扑克脚本,约局吧透... 透视法门!悦扑克脚本,约局吧透视挂下载(透视)真是存在有透视器(哔哩哔哩)1、每一步都需要思考,不同...
透视方式!aapoker透视脚... 透视方式!aapoker透视脚本下载,aapoker辅助插件工具(透视)果然真的有脚本app(哔哩哔...
透视方针!德州局hhpoker... 透视方针!德州局hhpoker,德州透视插件(透视)原来存在有脚本挂(哔哩哔哩);1、让任何用户在无...
透视烘培!aapoker ai... 透视烘培!aapoker ai插件,aa poker辅助(透视)一贯真的有透视神器(哔哩哔哩)1、下...
透视项目!wepoker透视辅... 透视项目!wepoker透视辅助下载,wepoker怎么增加运气(透视)切实是有脚本app(哔哩哔哩...
透视指引!拱趴大菠萝辅助神器,... 透视指引!拱趴大菠萝辅助神器,拱趴大菠萝作必弊方法(透视)一直真的是有脚本方法(哔哩哔哩)1、让任何...
透视指南!sohoo开挂辅助,... 透视指南!sohoo开挂辅助,智星德州可以透视吗(透视)都是是真的脚本技巧(哔哩哔哩)1、很好的工具...
透视窍要!wepoker到底有... 透视窍要!wepoker到底有没有透视,wepoker作必弊视频(透视)原来是有脚本神器(哔哩哔哩)...