In MariaDB, LCASE()
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).
LCASE()
is a synonym for LOWER()
.
Syntax
The syntax goes like this:
LCASE(str)
Where str
is the string to convert to lowercase.
Example
Here’s a basic example:
SELECT LCASE('Take Five');
Result:
+--------------------+ | LCASE('Take Five') | +--------------------+ | take five | +--------------------+
Here’s another example:
SELECT LCASE('SIDEKICK');
Result:
+-------------------+ | LCASE('SIDEKICK') | +-------------------+ | sidekick | +-------------------+
A Database Example
Here’s an example of converting the results of a database query to lowercase:
SELECT
PetName,
LCASE(PetName)
FROM Pets;
Result:
+---------+----------------+ | PetName | LCASE(PetName) | +---------+----------------+ | Fluffy | fluffy | | Fetch | fetch | | Scratch | scratch | | Wag | wag | | Tweet | tweet | | Fluffy | fluffy | | Bark | bark | | Meow | meow | +---------+----------------+
Binary Strings
LCASE()
doesn’t work on binary strings (BINARY
, VARBINARY
, BLOB
).
Example:
SELECT LCASE(BINARY 'SIDEKICK');
Result:
+--------------------------+ | LCASE(BINARY 'SIDEKICK') | +--------------------------+ | SIDEKICK | +--------------------------+
Null Arguments
Passing null
returns null
:
SELECT LCASE(null);
Result:
+-------------+ | LCASE(null) | +-------------+ | NULL | +-------------+
Missing Argument
Calling LCASE()
without passing any arguments results in an error:
SELECT LCASE();
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'LCASE'