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

相关内容

热门资讯

透视项目!aapoker透视方... 透视项目!aapoker透视方法,aa poker透视软件(透视)一直有脚本方法(哔哩哔哩)aa p...
透视窍门!hhpoker怎么防... 透视窍门!hhpoker怎么防作必弊(透视)开挂透视插件(哔哩哔哩)1、玩家可以在hhpoker怎么...
玩家必知教程!"心动... 玩家必知教程!"心动休闲辅助"原来是有辅助工具(揭秘有挂)-哔哩哔哩1、心动休闲辅助透视辅助软件激活...
透视方案!wejoker辅助器... 透视方案!wejoker辅助器怎么卖,德扑之心免费透视(透视)确实真的有挂(哔哩哔哩)1、wejok...
透视要领!wepoker私人局... 透视要领!wepoker私人局有透视吗(透视)开挂透视软件(哔哩哔哩)1、下载好wepoker私人局...
透视阶段!wpk可以作必弊吗,... 透视阶段!wpk可以作必弊吗,wpk辅助插件(透视)一直存在有脚本挂(哔哩哔哩)1、全新机制【wpk...
据了解"518互游辅... 据了解"518互游辅助"切实真的有辅助挂(有挂技巧)-哔哩哔哩1、518互游辅助辅助器安装包、518...
透视手筋!wejoker辅助脚... 透视手筋!wejoker辅助脚本,pokemmo手机版脚本免费(透视)切实真的有挂(哔哩哔哩)1、p...
透视操作!aapoker透视方... 透视操作!aapoker透视方法,aapoker怎么拿好牌(透视)确实有透视插件(哔哩哔哩);aap...
透视方式!wejoker黑侠辅... 透视方式!wejoker黑侠辅助器(透视)开挂透视app(哔哩哔哩)1)wejoker黑侠辅助器有没...