Deleting part of a string in MYSQL

前端 未结 2 1511
猫巷女王i
猫巷女王i 2020-12-14 15:25

I want to delete part of a string found in a particular field.

For example, the entry in the field could be \"01365320APS\". The \"APS\" is what I

相关标签:
2条回答
  • 2020-12-14 15:45

    For every occurrence of APS, try this:

    UPDATE table SET column=REPLACE(column,'APS','');
    

    Reference: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace

    0 讨论(0)
  • 2020-12-14 16:08

    When you want to edit a field, you need an UPDATE statement:

    UPDATE table SET fieldname=REPLACE(fieldname,'APS','')
    

    REPLACE is a string function that replaces every occurence of the 2nd string in the 1st string with the 3rd one.

    Please try this with a WHERE clause first, to see if it is really what you want to do.

    0 讨论(0)
提交回复
热议问题