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

相关内容

热门资讯

8分钟解谜!wpk辅助最怕三个... 8分钟解谜!wpk辅助最怕三个东西(透视)都是是真的挂,2025版教程(有挂分享)-哔哩哔哩1、wp...
透视软件!wejoker辅助脚... 透视软件!wejoker辅助脚本,steampokermaster辅助,绝活教程(有挂方略)-哔哩哔...
透视游戏!hhpoker辅助器... 透视游戏!hhpoker辅助器视频(透视)一直有挂,专业教程(有挂网页版)-哔哩哔哩1)hhpoke...
5分钟解迷!wpk私人局辅助是... 5分钟解迷!wpk私人局辅助是真的吗(透视)确实存在有挂,介绍教程(有挂细节)-哔哩哔哩1、wpk私...
透视代打!hhpoker透视脚... 透视代打!hhpoker透视脚本视频,wepoker网页版透视方法,手筋教程(真的有挂)-哔哩哔哩1...
透视有挂!wpk免费辅助(透视... 透视有挂!wpk免费辅助(透视)都是真的有挂,切实教程(有挂苹果)-哔哩哔哩1、任何wpk免费辅助a...
5分钟辅助!约局吧开挂(透视)... 5分钟辅助!约局吧开挂(透视)果然存在有挂,插件教程(有挂存在)-哔哩哔哩1、完成约局吧开挂的残局,...
透视app!hhpkoer辅助... 透视app!hhpkoer辅助器,wepokerplus辅助,阶段教程(有挂技术)-哔哩哔哩一、we...
透视脚本!wejoker透视方... 透视脚本!wejoker透视方法(透视)确实真的有挂,扑克教程(有挂工具)-哔哩哔哩1、透视脚本!w...
1分钟辅助!hhpoker有没... 1分钟辅助!hhpoker有没有辅助(透视)都是是真的挂,透明挂教程(有挂讲解)-哔哩哔哩1、hhp...