PDA

View Full Version : Need help with a query


JJR512
03-17-2002, 08:09 PM
Can someone show me a query I could use directly on the database that would search through EVERY message for a particular string and replace it with another string?

Or if that's not possible directly with a query, then a PHP script that would do it.

Mark Hensler
03-18-2002, 04:08 AM
not tested.. just a concept....

UPDATE table_name SET field_name=REPLACE(field_name, "find string", "replace string") WHERE id_field IN (SELECT id_field FROM table_name WHERE field_name LIKE '%find_string%')

OR

UPDATE table_name SET field_name=REPLACE(field_name, "find string", "replace string") WHERE field_name LIKE '%find_string%'


mySQL Docs:
6.3.2 String Functions (http://www.mysql.com/doc/S/t/String_functions.html)

Aaow AnD wHiTe
03-21-2002, 02:51 PM
Thanx, Mark :) We think that would be useful if you want to delete some smilies and don't want the code to stay in all messages. Has anyone tried it?