开发者

MySQL update Loop -> how to

I want to loop the following command, for all distinct values in a column

upd开发者_StackOverflow中文版ate myTable set myUglyField = replace(myUglyField,'<trimmed distinct value here>\r\n','<trimmed distinc value here>');

Anyone know if this could be done, instead of going one by one to remove \r\n


If you run that query you have right there it will update ALL rows in the table, so I think you're good.


Suppose you have all replacements in a table (3 columns, in which value, what to replace and the replacement), you can write:

update myTable join replacements on myTable.myUglyFied = replacements.in_value
set myUglyField = replace(myUglyField, replacements.what_to_replace, replacements.replacement)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜