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

相关内容

热门资讯

透视指南书!hh poker软... 透视指南书!hh poker软件(透视)开挂脚本工具(哔哩哔哩)1、全新机制【hh poker软件a...
透视积累!we poker辅助... 透视积累!we poker辅助器下载(透视)开挂脚本平台(哔哩哔哩)1、起透看视 we poker辅...
透视模块!sohoo辅助(透视... 透视模块!sohoo辅助(透视)开挂透视神器(哔哩哔哩)小薇(辅助器软件下载)致您一封信;亲爱soh...
透视模块!wpk俱乐部是真的吗... 透视模块!wpk俱乐部是真的吗(透视)开挂透视神器(哔哩哔哩)1、许多玩家不知道wpk俱乐部是真的吗...
透视练习!约局吧如何查看是否有... 透视练习!约局吧如何查看是否有挂(透视)开挂透视神器(哔哩哔哩)1、不需要AI权限,帮助你快速的进行...
透视步骤!哈糖大菠萝万能挂(透... 透视步骤!哈糖大菠萝万能挂(透视)开挂透视下载(哔哩哔哩)1、完成哈糖大菠萝万能挂有辅助插件,帮助玩...
透视办法!佛手在线有挂吗(透视... 透视办法!佛手在线有挂吗(透视)开挂脚本辅助器(哔哩哔哩)1、透视办法!佛手在线有挂吗(透视)开挂脚...
透视要领!wepoker辅助器... 透视要领!wepoker辅助器官方(透视)开挂透视软件(哔哩哔哩)1、wepoker辅助器官方透视辅...
透视手段!wepoker轻量版... 透视手段!wepoker轻量版辅助(透视)开挂透视平台(哔哩哔哩)1、点击下载安装,wepoker轻...
透视技法!有没有人wepoke... 透视技法!有没有人wepoker(透视)开挂脚本下载(哔哩哔哩)1、不需要AI权限,帮助你快速的进行...