SQL - Need to update thousands of posts - Updating a paticular part of my post

Status
Not open for further replies.

Ashleyuk1984

Active Member
1,242
2010
304
1,010
Hi,
I need help with some SQL queries. I'm trying to update all of my previous posts with a new image link.
This new image link will be replacing one that is currently already on the post.

Hopefully this diagram will help you understand what I'm trying to do.

(Click for larger version)

Warning - The image links in the posts are NSFW - So don't look at them if your around people.
(The below image is just text, but again contains NSFW words)




In the image you will see the following.
Original post, and original image link & Updated Post, with updated image link

I just need know how to (in SQL) update the original post to replace the original image link with the updated image link.

CMS = Wordpress

Thanks
 
Last edited:
2 comments
Hello,

You can try to download .sql file on computer and open it will notepad++ . Use find and replace method to replace text and save file .

Make sure that all changes done correctly and then import updated file into server.
 
if you know your old "text" and you have the new one.
just do a replace

Code:
UPDATE wp_posts
SET post_content = REPLACE(post_content, '<oldlink>', '<newlink>')
WHERE ID <=4
if you are sure all your links will only apply one time, you can skip the where clause. if not, use it :)
 
Status
Not open for further replies.
Back
Top