MySQL LCASE Function | Convert Text to Lowercase

MySQL LCASE is an inbuilt Function in MySQL. It converts a text to lowercase in MySQL. In this article, we will discuss the MySQL LCASE Function. Also, we will discuss a few examples of using it.

This function is synonymous to MySQL LOWER Function.

Syntax

LCASE (string)

Parameters

The Function expects only one parameter. You need to pass the string you need to convert in lowercase as the parameter.

Return Value

The function returns the input string to lowercase in MySQL.

MySQL LCASE Function

Examples

Let’s see some examples to use the function in queries.

Example 1: Basic Query

You can use the LCASE Function to convert a string to lowercase in MySQL.

mysql> SELECT LCASE('BRINGING KNOWLEDGE TOGEHTER') as lowerCase;
+-----------------------------+
| lowerCase                   |
+-----------------------------+
| bringing knowledge togehter |
+-----------------------------+
1 row in set (0.00 sec)

Example 2: SELECT Query

You can use the LCASE Function in SELECT statements.

mysql> SELECT LCASE(user_name) as lowerUserName FROM user_description;
+---------------+
| lowerUserName |
+---------------+
| chandler      |
| monica        |
| ross          |
+---------------+

Example 3: UPDATE Query

You can also update the existing fields in a table using the function in an UPDATE Query.

mysql> UPDATE user_description SET user_name = LCASE(user_name);
Query OK, 3 rows affected (0.07 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> SELECT user_name FROM user_description;
+-----------+
| user_name |
+-----------+
| chandler  |
| monica    |
| ross      |
+-----------+

Conclusion

In this article, we discussed the LCASE Function. It converts a text to lowercase in MySQL. You can read more about it on the Official MySQL Documentation. Also, read more about MySQL String Functions on Concatly.

Also, you can convert text to uppercase using MySQL UCASE Function.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *