Saturday, December 22, 2012

Lowercase all but the first letter

Problem
User's input all uppercase names. It needs to be normal casing or it messes up
the formatting of the page.
 
Solution
Run this MySQL script  
  
 
UPDATE `table` 
SET `field` = REPLACE(CONCAT(UPPER(LEFT(`field`, 1)), 
LOWER(SUBSTRING(`field`, 2))),' , ', ', ')
 
References
1. http://stackoverflow.com/questions/7238965/mysql-update-script-problem-all-txt-is-lower-case-just-first-letter-is-upper-ca  

No comments:

Post a Comment

There was an error in this gadget