MYSQL查询在所有帖子上查找和替换动态短语

时间:2013-03-22 01:18:43

标签: mysql

Based on our stats gathered across the U.S.        95%      of Flight Department Managers were males while        95%      were females.

我已经在几千个wordpress帖子上得到了这句话,其中飞行部门经理显然是这里的动态因素。

我需要做的是将前95%替换为%5,但仅限于此句中男性和女性均为95%的帖子。

所以上面的句子读为

Based on our stats gathered across the U.S.        5%      of Flight Department Managers were males while        95%      were females.

1 个答案:

答案 0 :(得分:0)

你可以这样写:

UPDATE table_name
   SET column_name = REPLACE(column_name, ' U.S.        95% ', ' U.S.        5% ')
 WHERE column_name REGEXP ' 95% .* 95% '
;