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)
精彩评论