Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

UCFIRST-Make first character Capital using MYSQL

Hello Friends,

MySQL database is the world's most popular open source database because of its fast performance, high reliability, ease of use, and dramatic cost savings. As i am using MYSQL with developing my PHP web application, i need to make a simple String operation in MYSQL and i would like to share it with you guys. I need to make a table field values to uppercase first character and than lowercase all other characters. There are UPPER and LOWER inbuilt functions available in MYSQL but it will make values to either uppercase or lowercase. If you need to make database field value to UCFIRST (Capitalize the first letter of each word using MYSQL) than below is the query. You can run it in mysql query command. This behave same as ucfirst function of PHP.

UPDATE countries SET `v_name` = CONCAT(UCASE(SUBSTRING(`v_name`, 1, 1)),LOWER(SUBSTRING(`v_name`, 2)));

If you find any problem in this than let me know by comment.


Leave a Reply

Your email address will not be published.