方法一:
1.把需要替换的数据查询出来
如下语句:
SELECT *
FROM wp_posts
WHERE post_content
REGEXP '[^S]+Shipment Terms.*western union, PayPal'
2.将此结果,导出到一个新的表,如:
create table wp_post_replace(
id int(10),
post_content text,
);
insert into wp_post_replace (id,post_content) SELECT id,post_content
FROM wp_posts
WHERE post_content
REGEXP '[^S]+Shipment Terms.*western union, PayPal'
3.将此查询结果导出为 一个SQL,保存在桌面。
4.用editplus打开此SQL,按ctrl+H,选择“正则替换”,将以下正则语法复制进去:
[^S]+Shipment Terms.*western union, PayPal
按全部替换,后保存。
5.清空 wp_post_replace表,将替换好的sql重新恢复。
6.运行下面语句:
UPDATE `wp_posts` SET `post_content` = ( SELECT post_content FROM wp_posts_replace WHERE id = wp_posts.id ) WHERE `post_content` REGEXP '<strong>[^S]+Shipment Terms</strong>.*western union, PayPal'
注意,导出到一个新的表,主要是在原数据库数据比较多的情况下,如果原数据库本身不大,可以直接导出此表的SQL进行正则替换,然后恢复即可。