Find-and-Replace in MySQL
Tags:
Picked this up at the mysql community on LiveJournal, one of the places there that is useful and not just entertaining.
If you need something more heavyweight, recent versions of MySQL have a
regexp function.It would be good to clarify whether this works on substrings also. Sorry if this is obvious, but I am getting ready to try this SQL on our database, and I'm hesitant to press enter :) I will verify the answer before I do.
Posted by: Patent Searcher on January 14, 2007 6:50 PM | permalinkUmm ... you shouldn't need me for that.
Just make a test table, and try it out for yourself.
That's a lot quicker (and more polite) than asking someone else to research something for free.
Posted by: Joe Grossberg on January 14, 2007 10:50 PM | permalinkThanks a lot, I was just searching for this!
Posted by: muztagh on March 10, 2007 1:30 AM | permalinkThis is great - fixed a problem instantly.
Posted by: Marc P Summers on April 16, 2007 5:43 AM | permalinkThanks for the info. Before I found this I used to export all my data into Excel!!
Posted by: pete on April 23, 2007 5:11 AM | permalinkYou saved me some bucks. A programmer told me it was complicated to change the comma (,) in a field to a period (.) for 1300 records. Thanks so much.
Posted by: Ellen Chen on July 31, 2007 9:20 AM | permalinkYou mention the use of regular expressions, but they can only be used to select data, because the REGEXP operator does not capture in MySQL.
There is apparently no way to do a preg_replace without external scripts...
Posted by: mauhiz on August 22, 2007 9:29 AM | permalinkThanks a lot...this was exactly what i was looking for...
Posted by: on December 31, 2007 4:51 AM | permalinkNo more comments! Either someone has violated Godwin's Law, I'm tired of the discussion or, most likely, the ten-week window has closed. You can, however, contact me through email.