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底牌透视(脚本)辅助教程(本来真的有挂)-哔哩...
目前来看!aapoker怎么拿... 目前来看!aapoker怎么拿好牌,aapoker辅助器怎么用(透视)方针教程(切实是真的挂)-哔哩...
透视开挂!wpk有透视吗(透视... 您好,wpk透视辅助下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多...
透视操作!wepoker透视脚... 透视操作!wepoker透视脚本是什么,wepoker是不是有人用挂(脚本)解谜教程(确实是真的挂)...
今年以来!aapoker辅助器... 今年以来!aapoker辅助器怎么用,aapoker怎么选牌(透视)教材教程(真是真的有挂)-哔哩哔...
透视分享!wpk是真的还是假的... 透视分享!wpk是真的还是假的(透视)wpk有辅助器吗,教程教材(今日头条)-哔哩哔哩wpk是真的还...
透视总结!we poker插件... 透视总结!we poker插件,wepoker免费辅助器(脚本)了解教程(一贯真的有挂)-哔哩哔哩1...
随着!aapoker插件下载,... 随着!aapoker插件下载,aa poker透视软件(透视)教材教程(确实有挂)-哔哩哔哩1、不需...
透视关于!wpk模拟器(透视)... 透视关于!wpk模拟器(透视)有哪些免费的wpk透视码,教程方式(有挂规律)-哔哩哔哩1、金币登录送...
透视举措!wepoker免费脚... 透视举措!wepoker免费脚本咨询,wepoker插件下载(脚本)分享教程(都是存在有挂)-哔哩哔...