How to use a MySQL statement to replace the last specified character of a value's contents

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.