How to Convert to Lowercase in MariaDB

In MariaDB, we can use the LOWER() function to convert uppercase characters to their lowercase equivalent.

We can alternatively use LCASE(), which is a synonym of LOWER().

Example

SELECT LOWER('QUIET Please');

Result:

quiet please

Any lowercase characters remain lowercase, while uppercase characters are converted to lowercase.

As mentioned, LCASE() is a synonym of LOWER() and so it does the same thing. Here’s a comparison of LOWER() and LCASE():

SELECT 
    LOWER('AZORIAN'),
    LCASE('AZORIAN');

Result:

+------------------+------------------+
| LOWER('AZORIAN') | LCASE('AZORIAN') |
+------------------+------------------+
| azorian          | azorian          |
+------------------+------------------+

Both return the same result.

Database Example

Here’s an example of converting the results of a database query to lowercase:

SELECT 
    Code,
    LOWER(Code)
FROM Country
LIMIT 10;

Result:

+------+-------------+
| Code | LOWER(Code) |
+------+-------------+
| ABW  | abw         |
| AFG  | afg         |
| AGO  | ago         |
| AIA  | aia         |
| ALB  | alb         |
| AND  | and         |
| ANT  | ant         |
| ARE  | are         |
| ARG  | arg         |
| ARM  | arm         |
+------+-------------+

Here I converted the Code column to its lowercase equivalent.

To convert the other way around (from lowercase to uppercase), we can use UPPER() and its synonym UCASE().