我知道,我可以通过
找到我需要的信息SELECT * from x6fnckq9h_posts
where post_status = 'publish' and post_content like '%new.%'
另外,我知道我可以用
替换字段中的文本update TABLE_NAME
set FIELD_NAME =
replace(FIELD_NAME, 'find this string', 'replace found string with this string');
我需要的是:用'%new.%'
''
那么,发送
是否正确update x6fnckq9h_posts
set post_content = replace(post_content, 'new.', '')
WHERE post_status = 'publish' and post_content like '%new.%';
答案 0 :(得分:1)
如果您感到紧张,请将更新转换为选择并注视输出以查看其是否正常:
select
post_content old_post_content,
replace(post_content, 'new.', '') new_post_content
from x6fnckq9h_posts
where post_status = 'publish'
and post_content like '%new.%'
如果您喜欢建议的更改,并且只要您使用完全相同的where子句,运行更新就可以了。
答案 1 :(得分:0)
只需对两个字段进行选择,而不是运行更新。
SELECT post_content, replace(post_content, 'new.', '')
FROM x6fnckq9h_posts
WHERE post_status = 'publish'
AND post_content like '%new.%';