Overview

The LOWER() function returns a given string, an expression, or values in a column in all lowercase letters. The syntax of the function is illustrated below:

LOWER(string)

It accepts input as a string and returns the text in the lowercase alphabet.

💡Special Cases: If there are characters in the input which are not of type string, they remain unaffected by the LOWER()function.

We support Unicode so that the ß is equivalent to the string ss.

Examples

#Case 1: Basic LOWER() function

The following basic query converts the given string in all lowercase alphabets:

SELECT LOWER('PostGreSQL');

The final output will be as follows:

+------------+
| lower      |
+------------+
| postgresql |
+------------+

#Case 2: LOWER() function using columns

Let’s see how the LOWER() function works using an example with columns. We have a personal_details table containing columns id, first_name, last_name, and gender of retail store employees.

CREATE TABLE personal_details (
  id int,
  first_name string,
  last_name string,
  gender string
);
INSERT INTO personal_details 
    (id, first_name, last_name, gender) 
VALUES 
    (1,'Mark','Wheeler','M'),
    (2,'Tom','Hanks','M'),
    (3,'Jane','Hopper','F'),
    (4,'Emily','Byers','F'),
    (5,'Lucas','Sinclair','M');
SELECT * FROM personal_details;

The above query will show the following table:

+-----+-------------+-------------+----------+
| id  | first_name  | last_name   | gender   |
+-----+-------------+-------------+----------+
| 1   | Mark        | Wheeler     | M        |
| 2   | Tom         | Hanks       | M        |
| 3   | Jane        | Hopper      | F        |
| 4   | Emily       | Byers       | F        |
| 5   | Lucas       | Sinclair    | M        |
+-----+-------------+-------------+----------+

Let’s assume that we want to convert the first and last names of employees with id numbers 2, 4, and 5 to all lowercase letters, which can be done using the following query:

SELECT first_name,last_name,LOWER(first_name),LOWER(last_name)
FROM personal_details
where id in (2, 4, 5);

The output displays the first and last names of employees with the specified ids in lowercase letters:

+------------+-------------+----------+----------+
| first_name | last_name   | lower    | lower    |
+------------+-------------+----------+----------+
| Tom        | Hanks       | tom      | hanks    |
| Emily      | Byers       | emily    | byers    |
| Lucas      | Sinclair    | lucas    | lucas    |
+------------+-------------+----------+----------+