All4172 Posted June 15, 2007 Share Posted June 15, 2007 What I'm trying to do is search a field in mysql, and if it has an _ in the file name, change it to a - instead. And alos change any capital letters to lower case. From: This_is_my_example To : this-is-my-example I figure it would be something like: UPDATE 'file' SET '-' WHERE `filename` LIKE '_' I"m not really sure how to put a regular expression in there to only replace the underscore put leave the data. Quote Link to comment https://forums.phpfreaks.com/topic/55750-mysql-query-statement-question/ Share on other sites More sharing options...
akitchin Posted June 15, 2007 Share Posted June 15, 2007 you can try using REPLACE(), which will simply replace any instance of a character with a given one: UPDATE table SET column = REPLACE(column, '_', '-') Quote Link to comment https://forums.phpfreaks.com/topic/55750-mysql-query-statement-question/#findComment-275430 Share on other sites More sharing options...
All4172 Posted June 15, 2007 Author Share Posted June 15, 2007 That worked great. Is there anything like that to convert capital letters to lower case? Quote Link to comment https://forums.phpfreaks.com/topic/55750-mysql-query-statement-question/#findComment-275434 Share on other sites More sharing options...
akitchin Posted June 15, 2007 Share Posted June 15, 2007 have a look at this section of the manual. it has all the mysql functions available to you, of which there are many. i believe the one you're asking for is UPPER(), but you'll want to make sure of that. Quote Link to comment https://forums.phpfreaks.com/topic/55750-mysql-query-statement-question/#findComment-275490 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.