mysql find/replace string in fields -


i have table has few varchar fields named this:

image_fullres | image_highres | image_mediumres | image_lowres | image_thumbnail

i have same value each of these fields(differing row), image_fullres has same path image_lowres , on.

an example value these paths http://mysite.com/images/image1.jpg

i have each of these fields contain different , appropriate path name, so:

  • image_fullres has value of http://mysite.com/images/fullres/image1.jpg
  • image_highres has value of http://mysite.com/images/highres/image1.jpg
  • image_mediumres has value of http://mysite.com/images/mediumres/image1.jpg

and on...

since of data in database duplicate paths row, sql can execute change value of each field's data appropriate path?

example:

update table  set image_fullres = replace(image_fullres, 'http://mysite.com/images/', 'http://mysite.com/images/fullres/') 

this update image_fullres column rows in table. can 1 such statement each column, or combine them one:

update table  set image_fullres = replace(image_fullres, 'http://mysite.com/images/', 'http://mysite.com/images/fullres/'), image_highres = replace(image_highres, 'http://mysite.com/images/', 'http://mysite.com/images/highres/'), ... ... 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -