当前位置:网站首页>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( )
边栏推荐
- proemthues 服务发现配置
- uniapp folding box secondary loop
- joiplay模拟器如何调中文
- 【LeetCode】55. 跳跃游戏 - Go 语言题解
- 写了多年业务代码,我发现了这11个门道,只有内行才知道
- Summary of the stock problem of state machine dynamic programming
- Android security optimization - APP reinforcement
- HF2022-EzPHP reproduction
- leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
- 【萌新解题】删除链表的倒数第 N 个结点
猜你喜欢

智能创意中的尺寸拓展模块

状态机动态规划之股票问题总结

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

Android安全性优化——APP加固

How to solve types joiplay simulator does not support this game

【LeetCode】70. 爬楼梯 - Go 语言题解

Steven Giesel recently published a 5-part series documenting his first experience building an application with the Uno Platform.

Reverse linked list - head insertion inversion method

joiplay模拟器如何使用

uniapp develops WeChat applet - soft exam brushing applet
随机推荐
【VisDrone数据集】YOLOV3训练VisDrone数据集步骤与结果
[0x800706D9] solution appears in Microsoft Store
如何在 AWS 中应用 DevOps 方法?
How to install joiplay emulator rtp
PS Basic Learning (1)
leetcode:127. Word Solitaire
How to adjust Chinese in joiplay simulator
牛逼的公司都在用的绩效管理法OKR
what is jira
[SAM template question] P3975 [TJOI2015] string theory
software development design process
软考学习计划
Steven Giesel 最近发布了一个由5部分内容组成的系列,记录了他首次使用 Uno Platform 构建应用程序的经验。
45.【list链表的应用】
Word文件损坏如何修复
leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
二叉查找树的定义,查找,插入,删除
Week 19 Progress (Understanding IoT Basics)
Shell script if statement
Learn Scope from a Compilation Perspective!