MySQL String Last Index Of

泄露秘密 提交于 2019-11-27 17:14:40

问题


I am able to use LOCATE to get the index of a character such as a . in www.google.com. Thus I can use substring to strip out everything before the first ..

Is there a way I can look for the last /?

So I can get test.htm out of http://www.example.com/dev/archive/examples/test.htm?

I do not want to say the 6th slash, I want to say the last slash. Can this be done?


回答1:


Use substring_index

select substring_index('http://www.example.com/dev/archive/examples/test.htm','/',-1)


来源:https://stackoverflow.com/questions/5796340/mysql-string-last-index-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!