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! Link to comment https://forums.phpfreaks.com/topic/35950-sql-update-with-wildcards/ 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 Link to comment https://forums.phpfreaks.com/topic/35950-sql-update-with-wildcards/#findComment-170491 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! Link to comment https://forums.phpfreaks.com/topic/35950-sql-update-with-wildcards/#findComment-170500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.