spacepoet Posted February 22, 2011 Share Posted February 22, 2011 Hello: Is there a feature or function (SQL Query) that can be used to change all UPPERCASE to just Capitalize the first letter of each word? I have a zipcode database and all the town names and state names are UPPERCASE, which is a bit unsightly and harder for the user to read. Anyway to do this? Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/ Share on other sites More sharing options...
darkfreaks Posted February 22, 2011 Share Posted February 22, 2011 Lower or Upper or Lcase() Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178003 Share on other sites More sharing options...
spacepoet Posted February 22, 2011 Author Share Posted February 22, 2011 Hi: Thanks, but not sure if I follow you. Is it a SQL Query that I would run in mySQL? Like: TO CAPITALIZE in zip_codes WHERE Column = towns Something like that? Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178005 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2011 Share Posted February 22, 2011 I don't believe mysql has a function that does that. PHP has ucwords, though. Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178013 Share on other sites More sharing options...
darkfreaks Posted February 22, 2011 Share Posted February 22, 2011 Select LCASE(first_name) from table; willoutput first name instead of FIRST NAME ucase does the opposite SELECT UCASE(first_name) from table will output FIRST NAME instead of first name if that doesnt work you can try this capitalize function that someone wrote for MYSQL. http://joezack.com/index.php/2008/10/20/mysql-capitalize-function/ Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178015 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2011 Share Posted February 22, 2011 The OP wants the first letter of each word capitalized. Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178017 Share on other sites More sharing options...
darkfreaks Posted February 22, 2011 Share Posted February 22, 2011 that's why i linked a page to a MYSQL capitalize function which does exactly that Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178018 Share on other sites More sharing options...
rajiv Posted February 22, 2011 Share Posted February 22, 2011 SELECT CONCAT( UCASE(LEFT(TRIM('MYSTRING'), 1)), UCASE(SUBSTRING(TRIM('MYSTRING'), 2)) ); This will capitalise all selected values.. This may helpful for you.. TreeShore Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178046 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2011 Share Posted February 22, 2011 that's why i linked a page to a MYSQL capitalize function which does exactly that I was using the WAP site my phone; the link didn't even show up on the screen . . . Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178171 Share on other sites More sharing options...
spacepoet Posted February 22, 2011 Author Share Posted February 22, 2011 Hi all: Thanks for all the input. I'm going to try the Capitalize FUNCTION and see how that goes. Looks like it makes sense. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178300 Share on other sites More sharing options...
fenway Posted February 23, 2011 Share Posted February 23, 2011 Besides, you can't be certain you even want every word capitalize. Quote Link to comment https://forums.phpfreaks.com/topic/228453-convert-all-uppercase-to-capitalized/#findComment-1178701 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.