Remove special characters from a database field

前端 未结 10 1689
梦如初夏
梦如初夏 2020-12-06 01:00

I have a database with several thousand records, and I need to strip down one of the fields to ensure that it only contains certain characters (Alphanumeric, spaces, and sin

10条回答
  •  旧时难觅i
    2020-12-06 01:49

    The Replace() function is first choice. However, Special Characters can sometimes be tricky to write in a console. For those you can combine Replace with the Char() function.

    e.g. removing €

    Update products set description = replace(description, char(128), '');
    

    You can find all the Ascii values here

    Ideally you could do a regex to find all the special chars, but apparently that's not possible with MySQL.

    Beyond that, you'd need to run it through your favorite scripting language.

提交回复
热议问题