Introduction to MySQL LOWERCASE
The following article provides an outline for MySQL LOWERCASE. To convert the string to lower case, we can do it by using the LOWERCASE function. The LOWERCASE has one argument which will accept the string and convert it into the lower case. The function used for the above functionality is LOWER() or LCASE(). Binary, BLOB and Varbinary are binary string data, these are not very effective when applied to the LOWER() function. To pass such data we first convert the string to non-binary string.
Syntax:
Syntax for the LOWERCASE function is as below:
LOWER( <string> / <column_name> )
Or
LCASE (<string> / <column_name>)
How does MySQL LOWERCASE works?
Now lets see how the LOWER() function works individually and in the table:
Code:
SELECT LOWER ( 'HI . . . WORLD' ) AS MESSAGE;
Here we can see that the <string> is mentioned as “HI . . . WORLD”. Above we are using the LOWER function to convert the ‘upper string’ to ‘lower string’.
Output:
Code:
SELECT LCASE( 'HI . . . WORLD' ) AS MESSAGE;
Here we can see that the <string> is mentioned as “HI . . . WORLD”. Above we are using the LCASE function to convert the ‘upper string’ to‘lower string’.
Output:
Now let us create a table and apply the LOWER () function:
Code:
CREATE TABLE LOWERCASE_DEMO (
ID INT,
UPPERCASE_VALUE VARCHAR(15)
);
Now let us insert data into the table:
Code:
INSERT INTO LOWERCASE_DEMO VALUES ( 1, 'BE INDEPENDENT');
INSERT INTO LOWERCASE_DEMO VALUES ( 2, 'BE CONFIDENT');
INSERT INTO LOWERCASE_DEMO VALUES ( 3, 'BE YOU');
INSERT INTO LOWERCASE_DEMO VALUES ( 4, 'BE POSITIVE');
INSERT INTO LOWERCASE_DEMO VALUES ( 5, 'BE REAL');
INSERT INTO LOWERCASE_DEMO VALUES ( 6, 'BE KIND');
INSERT INTO LOWERCASE_DEMO VALUES ( 7, 'BE GENEROUS');
INSERT INTO LOWERCASE_DEMO VALUES ( 8, 'BE FAMOUS');
INSERT INTO LOWERCASE_DEMO VALUES ( 9, 'YOU GOT THIS !!');
Now let us select the data from the table without applying the LOWER function. Output would be as below. Screenshot for the same. Here we could see that the data for the column ‘UPPERCASE_VALUE’ is in upper case. We are using the LOWER function and LCASE function to convert the characters into the LOWER case.
Code:
select * from LOWERCASE_DEMO;
Output:
Now let us see the LOWER function and LCASE function:
Code:
SELECT *, LOWER ( UPPERCASE_VALUE) AS LOWER_VALUE,
LCASE ( UPPERCASE_VALUE) AS LCASE_VALUE FROM LOWERCASE_DEMO;
Here in the above select statement, we could see that the instead of ‘string expression’ we have specified the ‘column name’. Which will convert the column values from the upper case to lower case as below. This is achieved by the LOWER function or LCASE function.
Output:
Examples of MySQL LOWERCASE
Given below are the examples of MySQL LOWERCASE:
Example #1
Now let us see how the LOWER () function works individually and in the table.
Multiple case in one string output gives lower case as well using the LOWER function.
Code:
SELECT LOWER( 'Hi . . . world QwErTy' ) AS MESSAGE;
Here we can see that the <string> is mentioned as ‘Hi . . . world QwErTy’. Which is combination of upper case and lower case. Once we are using the LOWER function to convert the ‘upper string’ to ‘lower string’. The lower characters will be converted to upper and upper case remains upper.
Output:
Code:
SELECT LCASE ( 'Hi . . . world QwErTy' ) AS MESSAGE;
Here we can see that the <string> is mentioned as ‘Hi . . . world QwErTy’. Which is combination of upper case and lower case. Once we are using the LCASE function to convert the ‘upper string’ to ‘lower string’. The lower characters will be converted to upper and upper case remains upper.
Output:
Example #2
Let us see another example for the LOWER and LCASE function as below.
Code:
CREATE TABLE COLLEGEDATA
(
COLLEGE_ID INT,
COLLEGE_NAME VARCHAR(50),
NO_OF_STUDENTS INT,
LOCATION VARCHAR(20)
);
Below data is inserted into the above table:
Code:
INSERT INTO COLLEGEDATA VALUES (1890, 'Narayana pvt college', 700000, 'Hyderabad');
INSERT INTO COLLEGEDATA VALUES (2890, 'St.Josephpvt college', 560000, 'Kerala');
INSERT INTO COLLEGEDATA VALUES (3890, 'Private Plan pvt college', 230000, 'Hyderabad');
INSERT INTO COLLEGEDATA VALUES (4890, 'Chorniclepvt college', 60000, 'Maharastra');
INSERT INTO COLLEGEDATA VALUES (5890, 'Number one pvt college', 780000, 'Hyderabad');
INSERT INTO COLLEGEDATA VALUES (6890, 'Startuppvt college', 500000, 'Uttar Pradesh');
Select the data from the above table and rows look as below:
Code:
SELECT * FROM COLLEGEDATA;
Now let us select the data from the table without applying the LOWER function.
Output:
Let us apply the LOWER and LCASE function:
Code:
SELECT COLLEGE_NAME,LOWER(COLLEGE_NAME),LCASE(COLLEGE_NAME)
,LOCATION , LOWER(LOCATION) , LCASE(LOCATION) FROM COLLEGEDATA;
Here we could see that the data for the column ‘ COLUMN_NAME’ is in upper case. We are using the LOWER function and LCASE function to convert the characters into the LOWER case.
Output:
Conclusion
To convert the string to lower case, we can do it by using the LOWER CASE function. The LOWERCASE has one argument which will accept the string and convert it into the lower case. The function used for the above functionality is LOWER () or LCASE (). Binary, BLOB and Varbinary are binary string data, these are not very effective when applied to the LOWER () function. To pass such data we first convert the string to non-binary string.
Recommended Articles
This is a guide to MySQL LOWERCASE. Here we discuss the introduction, how does MySQL LOWERCASE works? along with examples respectively. You may also have a look at the following articles to learn more –
12 Online Courses | 10 Hands-on Projects | 92+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses