Therefore, learning how to work with strings is very important. This article will teach you how to convert a string to lowercase using Standard SQL.
SQL Lower Function
The Lower function in Standard SQL allows you to convert a string to lowercase. The function syntax is as shown:
The function takes the string as an argument and returns the string with all the alphabetic characters converted to lowercase.
Take the example shown below:
The previous query should return the specified string in lowercase.
| LOWER |
| linuxhint |
Even if a string contains a mix of lowercase and uppercase characters, it will return lowercase results.
strings AS (
'LINUXHINT' AS str
'FO0' AS str
'BaR' AS str
LOWER(str) AS RESULT
The previous example statements should return all the strings converted to lowercase as shown below:
Note that the numeric characters do not affect the output.
SQL Update Existing Record to Uppercase
We can update an existing record to lowercase, as shown in the example below:
This should update the specified field value to lowercase.
This tutorial covered how to convert a string to lowercase using the Standard SQL Lower function. Most database engines adopt the lower function. However, you may find it under a different name, such as LCASE (Oracle), in some instances. Thanks for reading this article, and we hope you found it helpful. Check the other Linux Hint articles for more tips and tutorials.