当前位置:网站首页>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( )
边栏推荐
- How to ensure the consistency of database and cache data?
- what is jira
- transition transition && animation animation
- How to adjust Chinese in joiplay simulator
- @requestmapping注解的作用及用法
- 47. 【Pointers and Arrays】
- C# VSCode & Rider引用命名空间快捷键
- leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
- leetcode(刷题篇13)
- 在微服务中使用事件溯源的六大原因 - Herath
猜你喜欢

C# VSCode & Rider引用命名空间快捷键

joiplay模拟器如何使用

After writing business code for many years, I found these 11 doorways, which only experts know

递增三元组

Bugku sql注入

46.

软件开发设计流程

46.<list链表的举列>

In MySQL, the stored procedure cannot realize the problem of migrating and copying the data in the table

How to use joiplay emulator
随机推荐
动态修改el-tab-pane 的label(整理)
10 个关于自动化发布管理的好处
joiplay模拟器如何使用
常用的正则表达式
joiplay模拟器报错如何解决
xss绕过:prompt(1)
【萌新解题】删除链表的倒数第 N 个结点
How to solve types joiplay simulator does not support this game
How to adjust Chinese in joiplay simulator
封装、获取系统用户信息、角色及权限控制
MPI简谈
How to install joiplay emulator rtp
How to import game archives in joiplay emulator
joiplay模拟器如何导入游戏存档
(WebFlux)001、如何自定义注解实现功能
What are the efficient open source artifacts of VSCode
360核心安全大脑3.0正式发布,构建政企用户的“能力中枢平台”
"Wei cup" school more than 2022 cattle summer camp 4 L.B lack Hole, computational geometry
In MySQL, the stored procedure cannot realize the problem of migrating and copying the data in the table
Android security optimization - APP reinforcement