- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we capitalize only first letter of a string with the help of MySQL function/s?
Actually, there is no single function in MySQL to capitalize only first letter of the string. We need to use nesting of functions and for this case, we can use UPPER() and LOWER() with SUBSTRING() functions. To understand it, we are using data, given as below, from ‘emp_tbl’.
mysql> Select * from emp_tbl; +----+----------------+ | Id | Name | +----+----------------+ | 1 | rahul singh | | 2 | gaurav kumar | | 3 | yashpal sharma | | 4 | krishan kumar | | 5 | kuldeep rai | | 6 | munish nayak | +----+----------------+ 6 rows in set (0.00 sec)
We can see from the above result set that the first character of name string is in small letters. The following query will capitalize the first letter of string −
mysql> Select CONCAT(UPPER(SUBSTRING(name,1,1)),LOWER(SUBSTRING(name,2))) AS Name from emp_tbl; +----------------+ | Name | +----------------+ | Rahul singh | | Gaurav kumar | | Yashpal sharma | | Krishan kumar | | Kuldeep rai | | Munish nayak | +----------------+ 6 rows in set (0.00 sec)
- Pandas dataframe capitalize first letter of a column
- Capitalize first letter of a column in Pandas dataframe
- Python program to capitalize each word's first letter
- How can we filter data with the help of MySQL subquery?
- How can we know about the starting range of TIMESTAMP data type with the help of MySQL FROM_UNIXTIME() function?
- MySQL query to update all records to capitalize only the first letter and set all others in lowercase
- How can we subtract values in MySQL table with the help of LEFT JOIN?
- How can we apply BIT_LENGTH() function on the column/s of MySQL table?
- Which MySQL query can be used with the help of which we can see the list of MySQL databases?
- How can we insert values into a table with the help of MySQL self-computed output?
- How can we get the list of MySQL server-side help categories?
- How can we write MySQL query for inner joins with the help of Comma operator?
- How can we write MySQL query for inner joins with the help of keyword JOIN?