11-27-2012, 05:38 PM
|
|
marketer.
Industry Role:
Join Date: Aug 2006
Location: bcn
Posts: 2,280
|
Quote:
Originally Posted by Adraco
Do this, and follow Woj's precaution tips.
What I do, is to build a list of the words I want to replace, put them in Excel, in column A and downwards as far as I need to go (remember to use import as csv or whatever file format you have your 1000 words in).
And then do the same for column B for the words you want to replace with.
Then build a function, in column C, like:
update tablename set field=replace(A1','B1');
where A1 is the word you want to replace and B1 the word you want to replace with. Double click on the black square in the excel cell and let it auto fill downwards.
And then in column D, build then all together, with the & sign, like this:
=C1&C2&C3&C4
to make it return:
update tablename set field=replace(A1','B1');
update tablename set field=replace(A2','B2');
update tablename set field=replace(A3','B3');
update tablename set field=replace(A4','B4');
Then copy the full
update tablename set field=replace(A1','B1');
update tablename set field=replace(A2','B2');
update tablename set field=replace(A3','B3');
update tablename set field=replace(A4','B4');
and paste it into phpmyadmin in the SQL command line and run it.
Just remember that it is, indeed, very powerful, one mistake from you along the way and changes will be done accordingly, so be very careful and take al the necessary precautions!
|
lot of hassle like that. easier to script it imo.
quick basic script in php assuming using old mysql_ funcs
PHP Code:
<? $words = explode("\n","word1,replaceme word2,replaceme2, word3,replaceme 3 etc..."); foreach($words as $word) { $word = explode(",",$word); mysql_query('update table set field = replace(field,{$word[0]},{$word[1]}) '); }
?>
(completely untested)
|
|
|