How LOWER() Works in MariaDB

In MariaDB, LOWER() is a built-in string function that returns its string argument with all characters changed to lowercase.

The result is returned in the current character set mapping. The default is latin1 (cp1252 West European).

Another MariaDB function, LCASE() is a synonym for LOWER().

Syntax

The syntax goes like this:

LOWER(str)

Where str is the string to convert to lowercase.

Example

Here’s a basic example:

SELECT LOWER('Crazy Clown');

Result:

+----------------------+
| LOWER('Crazy Clown') |
+----------------------+
| crazy clown          |
+----------------------+

Here’s another example:

SELECT LOWER('FAST ELEPHANT');

Result:

+------------------------+
| LOWER('FAST ELEPHANT') |
+------------------------+
| fast elephant          |
+------------------------+

A Database Example

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

SELECT 
    StateProvince, 
    LOWER(StateProvince) 
FROM Vendors;

Result:

+---------------+----------------------+
| StateProvince | LOWER(StateProvince) |
+---------------+----------------------+
| MI            | mi                   |
| QLD           | qld                  |
| CA            | ca                   |
| NULL          | NULL                 |
| NULL          | NULL                 |
+---------------+----------------------+

Binary Strings

The LOWER() function doesn’t work on binary strings (BINARY, VARBINARY, BLOB).

Example:

SELECT LOWER(BINARY 'FAST ELEPHANT');

Result:

+-------------------------------+
| LOWER(BINARY 'FAST ELEPHANT') |
+-------------------------------+
| FAST ELEPHANT                 |
+-------------------------------+

Null Arguments

Passing null returns null:

SELECT LOWER(null);

Result:

+-------------+
| LOWER(null) |
+-------------+
| NULL        |
+-------------+

Missing Argument

Calling LOWER() without passing any arguments results in an error:

SELECT LOWER();

Result:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'LOWER'