当前位置:网站首页>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?

Apache Doris series: In-depth understanding of real-time analytical database Apache Doris

如何在WordPress网站上添加导航菜单

Week 19 Progress (Understanding IoT Basics)

joiplay模拟器如何调中文

xss绕过:prompt(1)

How to adjust Chinese in joiplay simulator

46.<list链表的举列>

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

Flex布局使用
随机推荐
Ukraine's foreign ministry: wu was restored to complete the export of food security
一款好用的接口测试工具——Postman
The first level must project independently
边缘计算与小程序也能结合!智能家居是否能借势上台阶
uniapp开发微信小程序-软考刷题小程序
How to adjust Chinese in joiplay simulator
background对float的子元素无效
MySQL面试题
How to solve the error of joiplay simulator
leetcode:127. Word Solitaire
Chevrolet Trailblazer, the first choice for safety and warmth for your family travel
【LeetCode】64. 最小路径和 - Go 语言题解
pytorch的安装注意事项
CPM:A large-scale generative chinese pre-trained lanuage model
[Meng Xin problem solving] Delete the Nth node from the bottom of the linked list
牛逼的公司都在用的绩效管理法OKR
Machine Learning 1-Regression Model (2)
Android安全性优化——APP加固
软件测试三阶段,你在哪一步?
Manually set transaction commit in mysql