LCASE Function in SQL

This string function shows all the string characters in the lower case in Structured Query Language. It converts the capital letter or set of capital letters into small letters.

Syntax of LCASE String Function

Syntax1: This syntax uses the LCASE function with the column name of the SQL table:

In this syntax, Column_Name is the name of that column whose values are to be shown in lower case.

Syntax2: This syntax uses the LCASE function with the set of upper case characters (string):

Syntax2: This syntax uses the LCASE function with the individual upper case character:

Examples of LCASE String function

Example 1: The following SELECT query converts all the characters of the following string in lower case (lcase):

Output:

javatpoint is a good website

Example 2: The following SELECT query cannot change the characters of the following string because the LCASE function cannot change the symbols and integers of the string in SQL.

Output:

@#$12453@#

Example 3: The following SELECT query converts the capital letters into small letters:

Output:

new delhi is the capital of india

Example 4: The following SELECT query shows the character 'S' in small in the output:

Output:

s

Example 5: This example uses the LCASE function with the SQL table

In this example, we are going to create a new table, which is to be used with the LCASE string function.

The syntax for creating the new table in the SQL database is as follows:

The following CREATE statement creates the Faculty_Info table:

The below INSERT queries insert the records of college Faculties in the Faculty_Info table:

The following SELECT statement displays the inserted records of the above Faculty_Info table:


Faculty_IdFaculty_First_NameFaculty_Last_NameFaculty_Dept_IdFaculty_AddressFaculty_CityFaculty_Salary
1001ARUSHSHARMA4001AMAN VIHARDELHI20000
1002BULBULROY4002NIRMAN VIHARDELHI38000
1004SAURABHROY4001SECTOR 128MUMBAI45000
1005SHIVANISINGHANIA4001VIVEK VIHARKOLKATA42000
1006AVINASHSHARMA4002SARVODYA CALONYDELHI28000
1007SHYAMBESAS4003KRISHNA NAGARLUCKNOW35000

The following SELECT query uses the LCASE function with the Faculty_Last_Name column of the above Faculty_Info table:

This SQL statement converts the last name of each faculty in small letters:

Output:

Faculty_Last_NameLCASE_LastName
SHARMAsharma
ROYroy
ROYroy
SINGHANIAsinghania
SHARMAsharma
BESASbesas

The following SELECT query uses the LCASE function with the Faculty_First_Name, Faculty_City, and Faculty_Address columns of those faculties whose faculty_Id is greater than 1002 in the above Faculty_Info table:

Output:

Faculty_IdLCASE(Faculty_First_Name)LCASE(Faculty_Address)LCASE(Faculty_City)
1004saurabhsector 128mumbai
1005shivanivivek viharkolkata
1006avinash sarvodyacalonydelhi
1007shyamkrishna nagarlucknow

The following SELECT query uses the LCASE function with the Faculty_Last_Name and Faculty_Address columns of those faculties whose faculty_Salary is greater than 30000 in the above Faculty_Info table:

Output:

Faculty_IdFaculty_Last_NameFaculty_Dept_IdFaculty_AddressFaculty_Salary
1002roy4002nirman vihar38000
1004roy4001sector 12845000
1005singhania4001vivek vihar42000
1007besas4003krishna nagar35000

Next TopicSQL MCQ