-1

I'd like to perform a find & replace in MySQL in GoDaddy's phpMyAdmin tool.

My table is called "wcswcd_posts", and I would like to find a URL, like:

http://wordpress.woodswcd.com/wordpress/wp-content/uploads/2013/11/drill.jpg

And replace it with:

/wordpress2/wp-content/uploads/2013/11/drill.jpg

Just not sure of what the syntax would be.

Thank you.

user1599076
  • 355
  • 1
  • 3
  • 5
  • 1
    This is a Q&A site, not your favorite search engine. Please search the web for "mysql replace" and your fine… If the problem is "not sure of what the syntax would be", you should always start in the official documentation: https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace – feeela Jul 28 '14 at 18:28

2 Answers2

2

You are going to need to use the UPDATE statement & the REPLACE function

to change it try:

UPDATE wcswcd_posts SET url = REPLACE(url,'http://wordpress.woodswcd.com','')

REPLACE is a string function that replaces every occurrence of the 2nd string in the 1st string with the 3rd one.

By setting the 3rd argument in the REPLACE function to nothing, you will get rid of any occurence of http://wordpress.wordswcd.com leaving /wordpress/wp-content/uploads/2013/11/drill.jpg

biw
  • 3,000
  • 4
  • 23
  • 40
0

This link should get you started.

Just replace http://wordpress.woodswcd.com/wordpress/ with http://wordpress.woodswcd.com/wordpress2/

Shashwat Black
  • 992
  • 5
  • 13
  • 24