SQL String Function LOWER()
In SQL, the LOWER()
function is used to convert a string to lowercase letters. It takes a single argument, which is the string to be converted, and returns a new string with all uppercase letters replaced by their lowercase counterparts.
Here is an example of using the LOWER()
function:
SELECT LOWER('Hello, World!') AS lowercase_string;
In this example, the LOWER()
function is used to convert the string 'Hello, World!'
to lowercase. The resulting string, 'hello, world!'
, is returned as the result of the query.
The LOWER()
function is commonly used when comparing strings for case-insensitive matches. For example, to find all rows in a table where the name
column contains the string 'john'
in any case, you could use the following query:
SELECT * FROM my_table WHERE LOWER(name) LIKE '%john%';
In this query, the LOWER()
function is used to convert the name
column values to lowercase, so that the LIKE
operator will match any occurrence of the string 'john'
in any case.
It's important to note that the LOWER()
function may behave differently in different database systems. Some systems may use different character sets or collations that affect the behavior of the function. As always, it's important to consult the documentation for your specific database system to ensure that you are using the function correctly.