SQL statement
Copy Code code as follows:
Reverse (substring reverse (path), 1,charindex ('/', reverse (path))-1)
How SQL takes out the character to the right of the last special character in a string, for example: 10*20*300, how do I get 300?
Use reverse with charindex to achieve.
Reverse is to invert the string, and then through the charindex to get the position of the first * after the inversion, and then use the SUBSTRING function to intercept the string, intercept and then use reverse inverted back.
Here is an example
DECLARE @str varchar (20)
Set @str = ' 10*20*300 '
Select reverse (substring (reverse (@str), 1,charindex (' * ', reverse (@str))-1)
The result is 300.
The above is SQL Server syntax.
Oracle database also has reverse functions, but substring to change to substr,charindex function to InStr function
SELECT Reverse (substr (reverse (' 10*20*300 '), 1,instr (reverse (' 10*20*300 '), ' * ')-1)) from DUAL;
The result is 300.