Reputation: 2006
I know, that I can find info that I need through
SELECT * from x6fnckq9h_posts
where post_status = 'publish' and post_content like '%new.%'
ALso, I know that I can replace text in the field with
update TABLE_NAME
set FIELD_NAME =
replace(FIELD_NAME, 'find this string', 'replace found string with this string');
What I need is: replace every '%new.%'
with ''
So, is it right to send
update x6fnckq9h_posts
set post_content = replace(post_content, 'new.', '')
WHERE post_status = 'publish' and post_content like '%new.%';
Upvotes: 1
Views: 215
Reputation: 48207
Instead of running update, just do a select with both fields.
SELECT post_content, replace(post_content, 'new.', '')
FROM x6fnckq9h_posts
WHERE post_status = 'publish'
AND post_content like '%new.%';
Upvotes: 0
Reputation: 425358
If you're nervous, turn the update into a select and eyeball the output to see if it looks OK:
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.%'
If you like the proposed changes, and as long as you use the exact same where clause, running your update will be OK.
Upvotes: 1