当前位置:网站首页>Substr and substring function usage in SQL
Substr and substring function usage in SQL
2022-07-27 10:50:00 【Golden% sunset】
sql Medium substr And substring The usage function
About substr and substring The difference between
First, declare ,substr() Is based on Oracle Of ,substring() Is based on SQL Server Of , Remember not to mix , Otherwise, an error will be reported !
MySQL: SUBSTR( ), SUBSTRING( )
Oracle: SUBSTR( )
SQL Server: SUBSTRING( )
1、Oracle Of substr
stay plsql in substr Is a separate function , String index with 1 Start .
grammar :
substr( string, start_position, [ length ] )
If start_position yes 0,substr Or do you think so 1 Start .
If start_position Positive number ,substr With start_position Start calculating , contain start_position.
If start_position It's a negative number , From string Start counting forward at the end .
length, Returns the length of the string , If it's a negative number , return NULL.
Example :
substr('This is a test', , 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', 1, 4) would return 'Tech'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
substr('TechOnTheNet', -8, 2) would return 'On'
2、javascript Medium substr and substring Two methods
stay javascript There is substr and substring Two methods , The index of the string is in 0 Start .
grammar :
substring Method is used to extract characters that are mediated between two specified subscripts .
stringObject.substring(start,stop)
explain :
substring The substring returned by the method includes start The character at , But does not include end The character at .
If start And end equal , Then the method returns an empty string ( The length is 0 String ).
If start Than end Big , Then the method will exchange these two parameters before extracting the substring .
If start or end It's a negative number , It will be replaced by 0.
substr Method is used to return a substring of a specified length starting at a specified position .
stringObject.substr(start [, length ])
explain :
If length by 0 Or negative numbers , Will return an empty string .
If the parameter is not specified , Then the substring will continue to stringObject Last .
Example :
"0123456789".substring(5) return "56789"
"0123456789".substring(0,5) return "01234"
"0123456789".substring(2,0) return "01"
"0123456789".substring(-1,5) return "01234"
"0123456789".substr(5) return "56789"
"0123456789".substr(2,0) return ""
"0123456789".substr(2,2) return "23"
"0123456789".substr(-1,5) return "01234"
3、java in substring yes string Object function
java in substring yes string Object function , Return to the location of String Object at the specified position . The index is from 0 Start calculation .
grammar :
strVariable.substring(start[,end])
substring Methods use start and end The smaller value of both is used as the starting point of the substring .strvar.substring(0,3) and strvar.substring(3, 0) Will return the same substring .
contain start The value of the location , It doesn't contain end The value of the location .
Example :
"05718888888".substring(0,4) returns "0571"
"hamburger".substring(4, returns "urge"
"smiles".substring(1, 5) returns "mile"
4、 summary :
except Oracle Of substr With 1 Index by string , The other two languages are based on 0 Action index .
java Of substring And javascript Of substring be similar .
javascript Of substr And Oracle/PLSQL Of substr be similar .
The source of the original text is :http://jw1314.iteye.com/blog/1211431
边栏推荐
- Echats关系图les-miserables的图表详细解析(和弦图)
- Eslint's error message module error (from./node_modules/ [email protected] @Eslint loader / index. JS)
- MySQL master-slave architecture, read-write separation, and high availability architecture
- PHP generates text and image watermarks
- Ubuntu and MySQL quick start tutorial
- Gamer questions
- 文档智能多模态预训练模型LayoutLMv3:兼具通用性与优越性
- flask_ Output fields in restful (resources, fields, marshal, marshal_with)
- 让人深思:句法真的重要吗?邱锡鹏组提出一种基于Aspect的情感分析的强大基线...
- 让人深思:句法真的重要吗?邱锡鹏组提出一种基于Aspect的情感分析的强大基线...
猜你喜欢

It is thought-provoking: is syntax really important? Qiu Xipeng group proposed a powerful baseline for aspect based emotional analysis

已解决SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated

多点双向重发布和路由策略
[email protected] @Eslint loader / index. JS) "/>Eslint's error message module error (from./node_modules/ [email protected] @Eslint loader / index. JS)

Data types and variables

MySQL日志管理、备份与恢复

php生成文字图片水印

服务器访问速度

ctf (hardrce)

文档智能多模态预训练模型LayoutLMv3:兼具通用性与优越性
随机推荐
Tensorflow notes - basic functions and concepts
Warning: remote head references to nonexistent ref, unable to checkout error messages
分享机器学习笔记(PDF版)+实战项目(数据集+代码)
Alibaba mailbox web login turn processing
让人深思:句法真的重要吗?邱锡鹏组提出一种基于Aspect的情感分析的强大基线...
[brother hero June training] day 25: tree array
tf.AUTO_ Function of reuse
Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
ASP. Net core dependency injection journey: 1. Theoretical concepts
Matlab- draw date and duration diagram
Awesome! VMware esxi installation record, with download
File upload vulnerability bypass method
WEB服务如何平滑的上下线
MySQL deadlock, pessimistic lock, optimistic lock
Redis data structure analysis (II)
Server access speed
7z usage
Li Kou brush question 02 (sum of three numbers + sum of maximum subsequence + nearest common ancestor of binary tree)
Basic statement of database operation
jvm--字节码浅析