LOWER

The SQL LOWER function is a built-in string function that converts all characters in a given string to lowercase. The syntax for the LOWER function is as follows:

LOWER(string)

Where string is the input string that you want to convert to lowercase.

Example

The LOWER function is often used to perform case-insensitive searches or comparisons in SQL queries. For example, if you have a table containing names of customers, and you want to retrieve all the customers whose names start with “j” or “J”, you can use the LOWER function to convert all the names to lowercase before performing the search, like this:

SELECT * 
FROM customers 
WHERE LOWER(name) LIKE 'j%';

In this example, the LOWER function is used to convert the name column to lowercase before checking if it starts with the letter “j” (using the LIKE operator).

It’s important to note that the LOWER function only affects alphabetical characters; it leaves any non-alphabetic characters (such as numbers or punctuation) unchanged. Also, the LOWER function does not modify the original string; it returns a new string that is the lowercase version of the input string.

In addition to the LOWER function, SQL also provides an UPPER function that performs the opposite operation (i.e., converts all characters to uppercase).