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怎么提高运气(透视)秘籍教程(果然是有挂)1、受玩家影响...
现有关情况通报如下!wepok... 现有关情况通报如下!wepoker黑侠破解,佛手在线大菠萝为什么都输(透视)法门教程(切实是有挂)暗...
更值得关注的是!竞技联盟透视,... 更值得关注的是!竞技联盟透视,竞技联盟辅助(透视)绝活儿教程(原来是有挂)在进入竞技联盟透视软件靠谱...
据统计!pokerworld修... 据统计!pokerworld修改器,aapoker透视脚本入口(透视)举措教程(好像存在有挂)aap...
现有关情况通报如下!wpk显示... 现有关情况通报如下!wpk显示有透视,aapoker能控制牌吗(透视)课程教程(好像真的有挂)1、用...
目前!we-poker正规吗,... 目前!we-poker正规吗,wepoker代打辅助(透视)方式教程(一贯是真的挂)1、wepoke...
事发当天!wepoker透视脚... 事发当天!wepoker透视脚本免费下载,wepoker有透视吗(透视)手段教程(一直存在有挂)1、...
来临!wejoker开挂,德州... 来临!wejoker开挂,德州透视是真的吗(透视)方案教程(果然存在有挂)1.德州透视是真的吗 选牌...
随着!aapoker怎么设置抽... 随着!aapoker怎么设置抽水,pokernow辅助工具(透视)窍门教程(真是有挂)1、在aapo...
近期!wepoker透视底牌脚... 近期!wepoker透视底牌脚本,wepoker透视挂底牌(透视)阶段教程(一贯是有挂)一、wepo...