Saturday, November 29, 2014

How to replace a character in MySQL table

Use this command in phpMyAdmin or in MySQL console:

update tablename set column_name = replace(column_name, 'character_to_be_replaced', 'characer_to_replaced_with');

For example:
I wanted to replace '&' with 'and' in table named 'tags' and column name 'tag' because that interfered with the URL.
I used following command

update tags set tag = replace(tag, '&', 'and');

I hope this help