

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 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 < valueLength ) do if (mid(value,l ,1) = ' ' or l = 0) then if (l < valueLength ) then set value= concat( left(value,l), lower(mid(value,l+ 1,1)), right(value,valueLength - l - 1) ); end if; end if; set l = l + 1; end while; return value; end; // Query OK, 0 rows affected (0.17 sec) mysql> 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)
- Related Questions & Answers
- How to implement the search functionality of a JTable in Java?
- Invert Result of MongoDB Query (Implement Opposite of $and operation)?
- How to find the opposite of %in% in R?
- How can we implement cut, copy and paste functionality of JTextField in Java?
- What the is the functionality of RBI?
- How to implement MySQL CASE with OR condition?
- Map the colors of the object to their opposite values in the color spectrum with CSS
- How to implement WHILE LOOP with IF STATEMENT MySQL?
- Implement specific record ordering with MySQL
- Opposite of $addToSet to '$removeFromSet' in MongoDB?
- How to add Google Search Functionality in Kotlin?
- How to implement Dictionary with Python3
- Implement MySQL REGEXP to fetch records with . and numbers
- Implement a query similar to MySQL Union with MongoDB?
- Implement MySQL CASE statement with WHEN clause
Advertisements