MyBB Community Forums

Full Version: Sql query for updating/replacing urls in mybb_posts?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
One of the troubles of transferring a forum to a different host, and using a different domain name is that all urls in the sql tables would still redirect to the old locations.

Example1: http://old forum url/showthread.php?tid=255

What is the sql syntax for a query that will globally change this to:

http://new forum url/showthread.php?tid=255

???
So far I have done a few individual queries using this:
SELECT *FROM `mybb_posts`WHERE `message` LIKE '%old forum url%'
LIMIT 0 , 30 

then edited the message section and saved it.

How can this be applied globally?

Thanks in advance.
UPDATE mybb_posts SET message=REPLACE(message, 'http://old forum url/showthread.php?', 'http://new forum url/showthread.php?')

as always this is dangerous and should not be done without making a backup first
(2009-05-17, 08:47 PM)frostschutz Wrote: [ -> ]UPDATE mybb_posts SET message=REPLACE(message, 'http://old forum url/showthread.php?', 'http://new forum url/showthread.php?')

That was a relief indeed. You saved me 800 manual changes.Wink

Thanks a million.

Best regards