MySQL字符串的最后一个索引 [英] MySQL String Last Index Of

查看:581
本文介绍了MySQL字符串的最后一个索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用LOCATE来获取字符的索引,例如www.google.com中的..因此,我可以使用子字符串删除第一个.之前的所有内容.

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 ..

有没有办法寻找最后 /?

所以我可以从http://www.example.com/dev/archive/examples/test.htm中取出test.htm吗?

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

我不想说第6个斜杠,我想说最后一个斜杠.能做到吗?

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

推荐答案

使用substring_index

Use substring_index

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

这篇关于MySQL字符串的最后一个索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆