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辅助器是真的吗,we-poker辅助器(确实是有挂)该软件可以轻松地帮助玩家...
透视透视!aa poker透视... 透视透视!aa poker透视软件(透视)透视脚本入口(切实真的是有挂)aa poker透视软件辅助...
透视规律(WPK)都是真的有挂... 透视规律(WPK)都是真的有挂(透视)wpk俱乐部有没有辅助(AA德州教程)1、游戏颠覆性的策略玩法...
透视最新!hhpoker真能买... 透视最新!hhpoker真能买到挂吗,hhpoker哪个俱乐部靠谱,wpk教程(有挂细节)透视最新!...
透视app!wejoker黑侠... 透视app!wejoker黑侠辅助器,wepoker新号好一点吗(果然有挂)1、玩家可以在wepok...
辅助透视!aapoker怎么开... 辅助透视!aapoker怎么开辅助器(透视)万能辅助器(总是是真的有挂)1、首先打开aapoker怎...
透视讲解(WPK)总是有挂(透... 透视讲解(WPK)总是有挂(透视)wpk控制牌是真的吗(教你教程)1、wpk控制牌是真的吗ai机器人...
透视插件!hhpoker可以控... 透视插件!hhpoker可以控制吗,hhpoker是正品吗,安装教程(有挂插件)1、完成hhpoke...
透视插件!wepoker提高好... 透视插件!wepoker提高好牌率,wepoker永久免费脚本(真是是有挂);1、点击下载安装,we...
透视辅助!aapoker免费透... 透视辅助!aapoker免费透视脚本(透视)可以设置抽水(好像是真的有挂)1、下载好aapoker免...