MySQL search and replace
How to perform a mySQL search and replace.
update tablename set field = replace(field,'search_for_this','replace_with_this');
If only I had found that earlier :-P
How to perform a mySQL search and replace.
update tablename set field = replace(field,'search_for_this','replace_with_this');
If only I had found that earlier :-P
Commentaires
garoo
Wow, weird syntax.
ap
You just saved my night :)
z33k
Thanks. Works great...
h8R
i've been searchin for this, thanks a lot ;)
Luke
And even after all this time, it's still helping people out. Saved me a ton of time. Thank you.
dshendler
Thanks! This helped me a lot.
I put it in camel casing so that it was more obvious for myself, and hopefully for others who find this:
UPDATE tablename SET fieldname = REPLACE(fieldname, 'badterm','goodterm')
As another commenter said, it is odd syntax. But it works like a champ.
dshendler
Thanks! This helped me a lot.
I put it in camel casing so that it was more obvious for myself, and hopefully for others who find this:
UPDATE tablename SET fieldname = REPLACE(fieldname, 'badterm','goodterm')
As another commenter said, it is odd syntax. But it works like a champ.
ajos1
Eeek-a-rama!
Sounds so simple... but I never realised that function ever existed... now I have a new toy to play with!!!
Ta's a-lot-o...
(Phew... I was about to write/[copy] my own version)
SiRoCs
Thanks a lot for the info! Very useful and time-saving!
muztagh
Thanks a lot, I was just searching for this.
Carl
Thanks man - lifesaver ! ;-)
tester
Wow, thanks so much!
Richard
I just wanted to clarify that the replacement works on the string and not the whole field.
Doug
Almost exactly 4 years later: THANK YOU!