Home » LCASE Function in SQL

LCASE Function in SQL

by Online Tutorials Library

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:

tutoraspire 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:

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_Id Faculty_First_Name Faculty_Last_Name Faculty_Dept_Id Faculty_Address Faculty_City Faculty_Salary
1001 ARUSH SHARMA 4001 AMAN VIHAR DELHI 20000
1002 BULBUL ROY 4002 NIRMAN VIHAR DELHI 38000
1004 SAURABH ROY 4001 SECTOR 128 MUMBAI 45000
1005 SHIVANI SINGHANIA 4001 VIVEK VIHAR KOLKATA 42000
1006 AVINASH SHARMA 4002 SARVODYA CALONY DELHI 28000
1007 SHYAM BESAS 4003 KRISHNA NAGAR LUCKNOW 35000

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_Name LCASE_LastName
SHARMA sharma
ROY roy
ROY roy
SINGHANIA singhania
SHARMA sharma
BESAS besas

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_Id LCASE(Faculty_First_Name) LCASE(Faculty_Address) LCASE(Faculty_City)
1004 saurabh sector 128 mumbai
1005 shivani vivek vihar kolkata
1006 avinashsarvodya calony delhi
1007 shyam krishna nagar lucknow

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_Id Faculty_Last_Name Faculty_Dept_Id Faculty_Address Faculty_Salary
1002 roy 4002 nirman vihar 38000
1004 roy 4001 sector 128 45000
1005 singhania 4001 vivek vihar 42000
1007 besas 4003 krishna nagar 35000

You may also like