SQL question to replace text in a field...............

I've searched the internet, and came up with these SQL statements, but number 2 won't work.



I'm trying to, in the full_description field, replace “type:” with “genre:”.



1 - SELECT * FROM cscart_product_descriptions WHERE full_description like '%type:%';

2 - update cscart_product_descriptions set full_description = replace(full_description, 'type:', 'genre:')



What is the correct SQL statement ?



Thank you, Duaine

This works well for me;



update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);




EXAMPLE:



update cscart_product_descriptions set full_description = replace(full_description, 'free shipping', 'flat-rate shipping');

It may only be a typo in your post but you have no SQL delimiter ' ; ' at the end of statement 2

Scott's right.

I use REPLACE all the time to update product descriptions en masse. It's very handy for fixing typos that you might have spread all over your descriptions.

I would recommend first creating a copy (with data) of any table you run the query on. This way you can always delete the table you edited and then rename (restore) the backup table if you end up with catastrophic results.