Home > Backend Development > PHP Tutorial > 如何使用mysql语句替换某一个值的内容的最后一个指定的字符

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

WBOY
Release: 2016-06-23 14:00:02
Original
1424 people have browsed it

回答前请先看这个帖子 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)update tbl_name set field_name=if(field_name RLIKE '/', substr(field_name,1,length(field_name)-1),field_name)update tbl_name set field_name=substr(field_name,1,length(field_name)-1) where field_name REGEXP '/$'update tbl_name set field_name=substr(field_name,1,length(field_name)-1) where field_name RLIKE '/''update tbl_name set field_name=left(field_name,length(field_name)-1) where field_name REGEXP '/$'update tbl_name set field_name=left(field_name,length(field_name)-1) where field_name RLIKE '/''
Copy after login

看着很爽,先结了

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