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

相关内容

热门资讯

透视绝活!德普之星透视辅助软件... 透视绝活!德普之星透视辅助软件是真的吗,如何下载德普之星辅助软件(透视)原来真的是有透视教程(哔哩哔...
透视讲义!德普之星辅助器app... 透视讲义!德普之星辅助器app,德普之星私人局辅助器(透视)真是是有脚本软件(哔哩哔哩)德普之星私人...
透视课程!hh poker软件... 透视课程!hh poker软件,hhpoker辅助软件(透视)一直真的是有透视脚本(哔哩哔哩)1)h...
透视妙计!德普之星app安卓版... 透视妙计!德普之星app安卓版破解版,德普之星有透视辅助吗(透视)其实真的有脚本攻略(哔哩哔哩)一、...
透视举措!hhpoker必备开... 透视举措!hhpoker必备开挂,hhpoker免费透视脚本(透视)其实真的有脚本教程(哔哩哔哩)1...
透视绝活!aapoker透视脚... 透视绝活!aapoker透视脚本下载,aapoker怎么开辅助器(透视)真是是真的脚本挂(哔哩哔哩)...
透视模块!We poker辅助... 透视模块!We poker辅助器下载,wepoker怎么设置透视(透视)都是是真的透视脚本(哔哩哔哩...
透视窍门!aapoker安装包... 透视窍门!aapoker安装包怎么使用,aapoker安装包怎么使用(透视)原来是真的脚本插件(哔哩...
透视绝活儿!aapoker怎么... 透视绝活儿!aapoker怎么拿好牌,aapoker万能辅助器(透视)都是是真的脚本教程(哔哩哔哩)...
透视方针!wepoker透视底... 透视方针!wepoker透视底牌,wepoker养号规律(透视)其实真的有脚本脚本(哔哩哔哩)1、w...