Adastra Posted January 27, 2007 Share Posted January 27, 2007 I need some quick help - I wanna run a UPDATE with a wildcard to mass edit the first part of an URL. What I've got in my database are things like http://myorldurl.net/images/myimage1.gif - with tons of different images or course. But what I wanna do is only change the http://myorldurl.net to http://mynewurl.org. How do I do that? I've tried UPDATE table SET url="http://mynewurl.org/%" WHERE url="http://myorldurl.net/%", but unfortunately that didn't work :/ I know there is some other way to do that, which probably involves LEFT or RIGHT statement, but I'm pretty clueless right now. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Tyche Posted January 27, 2007 Share Posted January 27, 2007 Use the MySQL REPLACE(str,from_str,to_str) string functionFor exampleUPDATE table SET url=REPLACE(url,"http://myorldurl.net/","http://mynewurl.org/") LIMIT 1;Try that and if it works on the first record remove the LIMIT 1 and re-run the query Quote Link to comment Share on other sites More sharing options...
Adastra Posted January 27, 2007 Author Share Posted January 27, 2007 ok i get it, thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.