怎么使用mysql语句替换某一个值的内容的最后一个指定的字符

WBOY
Release: 2016-06-13 11:52:49
Original
1442 people have browsed it

如何使用mysql语句替换某一个值的内容的最后一个指定的字符
回答前请先看这个帖子http://bbs.csdn.net/topics/390705363?page=1#post-396787221

如何使用mysql语句替换某一个值的内容的最后一个指定的字符“/”
比如
http://www.fuzhuang5.com/
http://www.haolvlv.com/shandonglvyou/index.htm
像上面这二个,最上面的那个是要替换的,而下面的这个是无需替换的,因为他最后面没有/字符
这个字段的值包括了很多的/ 我的需求是替换掉最后一个
这个字符串怎么把最后的一个“/”替换成空

这个update语句要怎么写



------解决方案--------------------
一下任何一句都可以
其实你原先的帖子已经有答案了

update tbl_name set field_name=if(field_name REGEXP '/$', substr(field_name,1,length(field_name)-1),field_name)<br />update tbl_name set field_name=if(field_name RLIKE '/', substr(field_name,1,length(field_name)-1),field_name)<br />update tbl_name set field_name=substr(field_name,1,length(field_name)-1) where field_name REGEXP '/$'<br />update tbl_name set field_name=substr(field_name,1,length(field_name)-1) where field_name RLIKE '/''<br />update tbl_name set field_name=left(field_name,length(field_name)-1) where field_name REGEXP '/$'<br />update tbl_name set field_name=left(field_name,length(field_name)-1) where field_name RLIKE '/''<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!