当前位置:网站首页>MySQL中substring与substr区别
MySQL中substring与substr区别
2022-07-31 00:00:00 【Miracle_ze】
substring与substr区别
substring
1.介绍
substring()是基于SQL Server的,用于截取字符串
2.使用
substring(start,stop)
两个参数是起止位置,包括“起”,不包括“止”,用区间表示就是[start,stop)。即第二个参数【stop】是截取字符串最终的下标
substr
1.介绍
substr()是基于Oracle的
2.使用
substr(start,length)
第一个参数是起始的位置,第二个参数是截取字符串的长度
substring与substr异同
相同点
1.两者均是截取字符串使用的函数
2.如果只是写一个参数,两者的作用都是一样的:就是截取字符串当前下标以后直到字符串最后的字符串片段
var a=”abcdefghiklmnopqrstuvwxyz”;
var b=a.substr(5);
var c=a.substring(5);
console.log(b);
console.log(c);
这样输出的结果就是一样的,都是
fghiklmnopqrstuvwxyz 从第五个下标是4的位置截取到最后
不相同点
1.两者的第二个参数有完全不同的含义;
substr(a,b)
第二个参数是截取字符串的长度
substring(a,b)
第二个参数是截取字符串最终的下标
var a="abcdefghiklmnopqrstuvwxyz";
var b=a.substr(3,5);
var c=a.substring(3,5);
打印输出的结果是:
defgh
de
2.substr()是基于Oracle的,substring()是基于SQL Server的,substr()与substring()两个都可以应用MySQL
MySQL: SUBSTR( ), SUBSTRING( )
Oracle: SUBSTR( )
SQL Server: SUBSTRING( )
边栏推荐
- Shell编程条件语句 test命令 整数值,字符串比较 逻辑测试 文件测试
- "NIO Cup" 2022 Nioke Summer Multi-School Training Camp 2 H.Take the Elevator
- The performance management method OKR is used by all companies
- leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
- Encapsulate and obtain system user information, roles and permission control
- [0x800706D9] solution appears in Microsoft Store
- proemthues 服务发现配置
- MySQL的一个问题
- ZZULIOJ: 1120: the most value to exchange
- 【VisDrone数据集】YOLOV4训练VisDrone数据集步骤与结果
猜你喜欢
46.<list链表的举列>
In MySQL, the stored procedure cannot realize the problem of migrating and copying the data in the table
2D Transform Module && Media Queries
SWM32系列教程6-Systick和PWM
joiplay模拟器报错如何解决
动态修改el-tab-pane 的label(整理)
el-upload添加请求头
uniapp开发微信小程序-软考刷题小程序
Shell programming conditional statement test command Integer value, string comparison Logical test File test
jira是什么
随机推荐
leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
Android security optimization - APP reinforcement
Game mall table establishment
.NET Cross-Platform Application Development Hands-on Tutorial | Build a Kanban-style Todo App with Uno Platform
46.
uniapp folding box secondary loop
借助深度估计的点云场景重建
在微服务中使用事件溯源的六大原因 - Herath
Debezium error series 20: task failed to create new topic. Ensure that the task is authorized to create topics
2021GDCPC Guangdong University Student Programming Competition H.History
How to solve types joiplay simulator does not support this game
如何在WordPress网站上添加导航菜单
2D转换模块&&媒体查询
Steven Giesel 最近发布了一个由5部分内容组成的系列,记录了他首次使用 Uno Platform 构建应用程序的经验。
ctfshow 文件包含
HF2022-EzPHP reproduction
Linux 部署mysql 5.7全程跟踪 完整步骤 django部署
二叉查找树的定义,查找,插入,删除
firewalld
How to solve the error of joiplay simulator