The SQL LOWER() function converts all the characters in a string into lowercase. The LOWER() function lowers the case of a string. For example, all the characters in the specified string will be converted to lowercase.
Use the UPPER() function to convert all characters in a string into uppercase in SQL. This is one of the String functions.
SELECT LOWER (input_string)
PARAMETERS:
Input_string: The string whose characters are to be converted to lowercase. The input string can be any string or any table column.
NOTE:
If any number is given as an input, it will remain unaffected.
Examples of LOWER() Function
Query 1
SELECT LOWER ('APPDIVIDEND.COM');
Output
appdividend.com
Query 2
SELECT LOWER ('AppDividend.com');
Output
appdividend.com
Query 3
SELECT LOWER ('SQL is FuN');
Output
sql is fun
Query 4
SELECT LOWER (‘ABC123DEF’);
Output
abc123def
As mentioned above, numerals are unaffected by the lower function.
Above are common examples to make you clear how this function works.
Let’s apply this to a table.
TABLE: (Employee)
Emp_id | First_name | Last_Name | City | State | Phone |
101 | Rohit | Raj | Patna | Bihar | 8585145852 |
201 | Shivam | Kumar | Jalandhar | Punjab | 8958458785 |
301 | Karan | Kumar | Allahabad | Uttar Pradesh | 9987845784 |
401 | Suraj | Gupta | Kolkata | West Bengal | 88789898980 |
501 | Akash | Jain | Vizag | Andhra Pradesh | 98985475001 |
Let’s display the employee’s full name by converting all its characters to lowercase.
QUERY
SELECT First_name, Last_name, CONCAT_WS (' ', LOWER (First_name), LOWER (Last_name)) Full_name FROM Employee;
Output
First_name | Last_Name | Full_name |
Rohit | Raj | rohit raj |
Shivam | Kumar | shivam rana |
Karan | Kumar | karan kumar |
Suraj | Gupta | suraj gupta |
Akash | Jain | akash jain |
Here you can see that full_name is displayed under the column name Full_name whose characters are lowercase.
The names are separated by a space using the concat_ws() function.
MySQL LOWER() Function
MySQL LOWER() function converts all the characters in a string to lowercase characters.
Query
SELECT LOWER('APPDIVIDEND');
Output
+-----------------------+ | LOWER('MYTESTSTRING') | +-----------------------+ | appdividend | +-----------------------+
SQL Server LOWER() Function
The SQL LOWER() function converts all the characters in a string into lowercase.
Query
SELECT LOWER('KRUNAL LATHIYA');
Output
krunal lathiya (1 row)
That’s it.