Home Learn More Purchase Knowledge Base Support Contact

Search:     Advanced search

How can I do a mass find and replace in articles?

Article ID: 189
Last updated: 18 Dec, 2010

You can write one-line find-and-replace statements in SQL.
To find a string in a certain field and replace it with another string:

UPDATE [table_name] SET [field_name] = REPLACE([field_name],'[string_to_find]','[string_to_replace]');


To not affect date updated for the articles use following sql:

UPDATE [table_name] SET [field_name] = REPLACE([field_name],'[string_to_find]','[string_to_replace]'), date_updated=date_updated;


To find what articles will be affected:

SELECT [field] FROM [table_name] WHERE [field_name] LIKE '%[string_to_find]%';


Example: replace "apple" to "banana" in all articles

UPDATE kbp_kb_entry SET body = REPLACE(body,'apple','banana'), date_updated=date_updated;
Article ID: 189
Last updated: 18 Dec, 2010
Views: 3701
Comments: 0
This article was:  
Prev   Next
How can I backup and restore database?     How to change ft_min_word_len variable


© 2011 Double Jade LLC | customer.service@kbpublisher.com