Search code examples
mysqlsqldatabase

Remove special characters from a database field


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 single quotes). What SQL can I use to strip any other characters (such as slashes, etc) from that field in the whole database?


Solution

  • update mytable
    set FieldName = REPLACE(FieldName,'/','')
    

    That's a good place to start.