Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to implement the opposite of INITCAP() functionality with MySQL?
The INITCAP() method display the first character in every word in uppercase and rest in lowercase.
To implement the opposite functionality, you need to create your own function in MySQL. Here’s the function −
mysql> delimiter // mysql> create function convertFirstLetterToLowerAndRemainingToCapital(value varchar(250)) returns varchar(250) deterministic begin declare valueLength int; declare l int; set valueLength = char_length(value); set value = upper(value); set l = 0; while (l delimiter ;
Call the function with the help of select statement −
mysql> select convertFirstLetterToLowerAndRemainingToCapital('Introduction To MySQL');
This will produce the following output −
+-------------------------------------------------------------------------+
| convertFirstLetterToLowerAndRemainingToCapital('Introduction To MySQL') |
+-------------------------------------------------------------------------+
| iNTRODUCTION tO mYSQL |
+-------------------------------------------------------------------------+
1 row in set, 2 warnings (0.04 sec) Advertisements
