Replace a string with another string in MySQL

10 Mar
2009

This is a real timesaver. Instead of updating all your x records, you simple execute the following query:

UPDATE table SET column_name = REPLACE(column_name,"string_to_replace","string_new")

In this example I replace all the é’s that exist in the database to its proper version:

UPDATE contents SET content = REPLACE(content,"é","é")

Enjoy!

Feel free to share:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • Technorati

Comment Form

top