The substr (string, 1, 3) function reads: A string that takes a 3 word length from the left to the right.
The result: Str
From right to left?
There should be another function to provide such a function!
In fact, from right to left this function is just a different parameter.
SUBSTR (string,-1,3) Functional Interpretation: Take the 1 bits to the right of the String to start with 3 bits.
The result is: g
SUBSTR (String,start,length)
String-The specified strings to intercept.
Start-required to specify where to start the string. Positive number-starting at the specified position of the string, minus-starting at the specified position at the end of the string, 0-starting at the first character in the string.
Length-Optionally, specifies the length of the string to intercept, and returns all characters before the end of the value of the character expression by default.
For example: Select substr (' ABCDEFG ', 3,4) from dual; The result is cdef.
Select substr (' ABCDEFG ', -3,4) from dual; Results EFG
Note: The first position in the string is always 1. The results of the following two SQL queries are the same:
For example: Select substr (' ABCDEFG ', 0,3) from dual; The result is ABC.
Select substr (' ABCDEFG ', 1,3) from dual; The result is ABC.
differs from the substring in Java classes:
substring (int beginindex, int endindex): Starts at the specified beginindex, ends at the specified endIndex-1, and the first position in the string is always 0. Endindex, optionally, returns the character that starts at the specified index by default until the end of the string.
For example: "Unhappy". SUBSTRING (2) returns "Happy"
"Hamburger". Substring (3,8) returns "Burge"
The above mentioned is the entire content of this article, I hope you can enjoy.