Find and Replace in MySQL
Posted October 26th, 2006 @ 01:40am by Erik J. Barzeski
This has come in handy the past few days. If only I could do it with regular expressions… and if only I knew regular expressions! 🙂
update [table_name] set [field_name] = replace([field_name], '[string_to_find]', '[string_to_replace]');
Works like a charm… though I'm not entirely sure how to replace line breaks. Some of my MT entries have four line breaks where they should have two.
Donate Life
Posted 26 Oct 2006 at 8:47am #
There is also a plugin to do SQL search and replace from within WordPress.
Posted 28 Oct 2006 at 9:25pm #
You do have POSIX Regexp support in MySQL, but as far as I know you can only do matching and not replacing with it..