Please read this post before you answer http://bbs.csdn.net/topics/390705363?page=1#post-396787221
How to use a MySQL statement to replace the last specified character "/" of a value's contents
Like what
http://www.fuzhuang5.com/
Http://www.haolvlv.com/shandonglvyou/index.htm
Like the top two, the top one is to be replaced, and the following one is not replaceable because he has no/character at the back.
The value of this field includes a lot of/my requirements is to replace the last one
How does this string replace the last "/" with an empty one?
How to write this update statement
Reply to discussion (solution)
You can have any one sentence.
Actually, your original post already has an answer.
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 '/'
It's good to see, first knot.