sql update replace

Avatar
  • Answered
I need to replace all instances of http://oldwebsite with http://newwebsite with out removing other content in Column. Where can I get me some cookies? 

Need it to be changed to. Where can I get me some cookies? 

Will the update replace do this without removing every thing else. UPDATE posts SET content = replace(content, 'http://oldwebsite/da/', 'http://newwebsite/da/' ) ;
Avatar
jamesr
Thank you for your question False007! You can run an SQL statement; however, this will change your live database. If the SQL statement goes wrong for any reason, your live copy can be damaged. You can export your database as an SQL file to your local computer. Make a copy of it, then use find and replace in a text editor like Notepad++ to find and replace all instances of the old domain with the new domain. After you get the backup copy updated you can Import the database on your server. This way you can prevent any problems that may arise when changing the URL and keep a back up of the database. Best Regards, James R
Avatar
BradM
Hi False007, The syntax for you Update query looks correct at first look. As long as the information you want to change is in the posts table and specifically in the content column, you should be OK. To be on the safe side however, but sure to generate a backup of your database before running a command like this. I hope that helps! Let us know if we can help any further. Thanks, - Brad