In this tutorial, we will look at how to use the MySQL lower function (also know as the MySQL to lower function). This is an in-built MySQL function which takes a string as its only parameter and returns a new string with all the characters converted to lowercase according to the mapping of the character set which is currently in use.
In most cases, this simply means that the MySQL lower function will return all alphabetical letters in their lowercase (uncapitalised) form. Strings are usually converted to lowercase for consistency or for other reasons depending on the application.
Have a look at the MySQL lower tutorial below to learn how this useful function works.
The to lower function in MySQL is simple and takes a single parameter as its argument.
-- Simply pass the string that you want to be converter to lowercase LOWER(string);
As you can see above, the syntax is very simple. Let's go on to some examples of the MySQL lower function.
Here is an example of the MySQL "to lower" function at work:
SELECT LOWER('TutorialArena'); -- gives 'tutorialarena'
Here are 2 more examples:
SELECT LOWER('HaHa Lol'); -- gives 'haha lol'
SELECT LOWER('ABCDxyZ'); -- gives 'abcdxyz'
Pretty simple, isn't it? Play around with them in MySQL and see how they work.
As with the MySQL upper function, the MySQL lower function does not work on binary strings such as those of the type BINARY, VARBINARY, and BLOB. If we wanted to convert a string of one of those types to lowercase we would need to first convert it to a non-binary string.
The following example explains:
SET @string = BINARY 'Tutorial Arena'; SELECT LOWER(@string); -- Gives the same 'Tutorial Arena' SELECT LOWER(CONVERT(@string USING latin1)); -- Gives 'tutorial arena'
And that's it. We hope you found this tutorial on the MySQL LOWER function useful.