Here’s a sample table:
name | picture John S. | http://servera.host.com/johns.png Linda B. | http://servera.host.com/lindab.png ...
Let’s say there are several hundred more records.
Let’s also say we moved servers from “servera” to “serverb”.
Would it be possible to go into this table with one query to rename the content in the column “picture” for every record to read the correct server name?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
update TBL set picture = Replace(picture, 'servera', 'serverb') where picture like '%servera%'
update TBL set picture = replace(picture, 'servera', 'serverb') where picture like '%servera%'
update TBL set picture = REPLACE(picture, 'servera', 'serverb') where picture like '%servera%'
UPDATE users SET picture = REPLACE(picture, 'http://servera.host.com/', 'http://serverb.host.com/') WHERE picture LIKE 'http://servera.host.com/%';
I’m including more of the string because I’d worry about ‘fixing’ an image named ‘somethingserverasomething.jpg’. I might also think about having a base_url table and just storing image file names in users, but that’s not the question you asked 😉