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

相关内容

热门资讯

于此同时!蜀渝牌乐汇挂机软件(... 于此同时!蜀渝牌乐汇挂机软件(辅助挂)原来是有挂的(有挂手册)-哔哩哔哩1、于此同时!蜀渝牌乐汇挂机...
围绕透视问题!wepokerp... 围绕透视问题!wepokerplus辅助(透视)其实是有挂(有挂工具开挂辅助工具)-哔哩哔哩1、we...
不少玩家反映!来玩app破解,... 不少玩家反映!来玩app破解,德扑之心免费透视,手段教程(果然透视有挂)-哔哩哔哩1.德扑之心免费透...
今日!牌乐们黑科技试用(辅助挂... 今日!牌乐们黑科技试用(辅助挂)一贯是有挂的(有挂要领)-哔哩哔哩牌乐们黑科技试用辅助器中分为三种模...
长期以来!hhpoker德州机... 长期以来!hhpoker德州机器人(透视)果然真的是有挂(有挂透视开挂辅助下载)-哔哩哔哩1、该软件...
相较于以往!wepoker有插... 相较于以往!wepoker有插件吗,hhpoker的辅助是真的吗,练习教程(其实透视真的有挂)-哔哩...
今日!约局吧辅助(辅助挂)一贯... 今日!约局吧辅助(辅助挂)一贯是有挂(有挂练习)-哔哩哔哩1、约局吧辅助透视辅助简单,约局吧辅助软件...
最新消息!wepoker好友助... 最新消息!wepoker好友助力码(透视)其实是有挂(有挂教程开挂辅助神器)-哔哩哔哩一、wepok...
推出新举措!xpoker辅助怎... 推出新举措!xpoker辅助怎么用,wepoker有透视功能吗,手段教程(果然透视是有挂的)-哔哩哔...
随着!微信老友广东辅助(辅助挂... 随着!微信老友广东辅助(辅助挂)果然真的是有挂(有挂积累)-哔哩哔哩1、下载好微信老友广东辅助辅助软...