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.

About Rakshit Patel
I am PHP Freelancer, Rakshit Patel AKA WordPress Freelancer working as PHP Programmer India. I am here to share all my developing knowledge, quick coding techniques, quick solutions to save your time and help you guys for any issue or bug fixing. If you have any PHP, WordPress, Magento related work, please contact me. I am interested for the work.

2 Comments on UCFIRST-Make first character Capital using MYSQL

  • Steve Gath
    September 1, 2011 at 1:52 am

    This only does the first word not each word like the PHP function.

  • David
    September 29, 2011 at 5:22 am

    This is exactly what I was looking for! Thanks a bunch. It’s now part of my SQL txt cheat sheet. :-)

Leave a Reply

Your email address will not be published. Required fields are marked *




DHgate Computers
DHgate.com - Computers, Cell Phones & more
  • We find everbuying built in php and use css to control the style.

About Author

PHP Freelancer

PHP Freelancer I am PHP Freelancer, Rakshit Patel working as PHP Programmer India. I am here to share all my developing knowledge with you people. For Hire PHP Developer India, contact me.
Follow on twitter: @raxit4u2

Get Free Programming Tutorials:

Become a Fan

Popular Topics

Recent Posts

Most Popular

Recent Comments

Get a Free Quote
Security Question: 3 + 8 = ?
Listing all pages