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养号规律(透视)开挂脚本辅助器(哔哩哔哩)1、操作简单,无需wepoker养...
透视步骤!hh poker透视... 透视步骤!hh poker透视器下载(透视)开挂透视app(哔哩哔哩)1、首先打开hh poker透...
透视演示!we poker辅助... 透视演示!we poker辅助器v3.3(透视)开挂脚本神器(哔哩哔哩)进入游戏-大厅左侧-新手福利...
透视攻略!云扑克有透视吗(透视... 透视攻略!云扑克有透视吗(透视)开挂脚本修改器(哔哩哔哩)1、下载好云扑克有透视吗正确养号方法之后点...
透视学习!aapoker安装包... 透视学习!aapoker安装包怎么使用(透视)开挂脚本下载(哔哩哔哩);1、aapoker安装包怎么...
透视演示!we-poker辅助... 透视演示!we-poker辅助器(透视)开挂脚本辅助器(哔哩哔哩)1.we-poker辅助器 选牌创...
透视总结!德州真人透视脚本(透... 透视总结!德州真人透视脚本(透视)开挂透视辅助器(哔哩哔哩)1、德州真人透视脚本模拟器是什么优化,德...
透视方针!wpk免费辅助(透视... 透视方针!wpk免费辅助(透视)开挂透视工具(哔哩哔哩)1、游戏颠覆性的策略玩法,独创攻略技巧玩法,...
透视技法!hhpoker买挂(... 透视技法!hhpoker买挂(透视)开挂脚本app(哔哩哔哩)1、进入游戏-大厅左侧-新手福利-激活...
透视步骤!德普之星透视免费(透... 透视步骤!德普之星透视免费(透视)开挂脚本工具(哔哩哔哩)1、玩家可以在德普之星透视免费透视最简单三...