dyluck Posted August 9, 2010 Share Posted August 9, 2010 Hi there, Does anyone have a sql query to replace a piece of string? I have many rows in a column with various filenames like blaa.gz baaaa.gz etc. I need to find the .gz and replace with .zip Is that possible in a mysql query? Thanks, dyluck Quote Link to comment https://forums.phpfreaks.com/topic/210178-partial-string-replace/ Share on other sites More sharing options...
JasonLewis Posted August 9, 2010 Share Posted August 9, 2010 Yeah, should be, using REPLACE. UPDATE tablename SET fieldname = REPLACE(fieldname, '.gz', '.zip') WHERE idfield='1' Quote Link to comment https://forums.phpfreaks.com/topic/210178-partial-string-replace/#findComment-1096854 Share on other sites More sharing options...
dyluck Posted August 9, 2010 Author Share Posted August 9, 2010 Worked like a charm! thanks! Quote Link to comment https://forums.phpfreaks.com/topic/210178-partial-string-replace/#findComment-1096857 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.