w3resource

MySQL LOWER() function

LOWER() function

MySQL LOWER() converts all the characters in a string to lowercase characters.

This function is useful in -

  • Lowercase conversion: This converts all uppercase characters in a string to lowercase.
  • Data normalization: The LOWER() function can be used to normalize strings within your data.
  • Case-insensitive comparisons: Lower() is often used with comparison operations to perform case-insensitive comparisons.

Syntax:

LOWER(str)

Argument:

Name Description
str A string whose characters are going to be converted to lowercase.

Syntax Diagram:

MySQL LOWER() Function - Syntax Diagram

MySQL Version: 8.0

Example: MySQL LOWER() function

The following MySQL statement returns the given string after converting all of its characters in lowercase.

Code:

SELECT LOWER('MYTESTSTRING');

Output:

mysql> SELECT LOWER('MYTESTSTRING'); 
+-----------------------+
| LOWER('MYTESTSTRING') |
+-----------------------+
| myteststring          | 
+-----------------------+
1 row in set (0.01 sec)

Example of LOWER() on column of a table

The following MySQL statement returns those rows from the publisher table whose publishers does not belong to the USA. The column pub_name and after converting the pub_name column in lowercase is displayed in the output.

Code:

SELECT pub_name,LOWER(pub_name) 
FROM publisher 
WHERE country<>'USA';

Sample table : publisher

Output:

mysql> SELECT pub_name,LOWER(pub_name) 
    -> FROM publisher 
    -> WHERE country<>'USA';
+------------------------------+------------------------------+
| pub_name                     | LOWER(pub_name)              |
+------------------------------+------------------------------+
| BPP Publication              | bpp publication              | 
| New Harrold Publication      | new harrold publication      | 
| Ultra Press Inc.             | ultra press inc.             | 
| Pieterson Grp. of Publishers | pieterson grp. of publishers | 
| Novel Publisher Ltd.         | novel publisher ltd.         | 
+------------------------------+------------------------------+
5 rows in set (0.00 sec)

Video Presentation:

All String Functions (Slides presentation)

Previous: LOCATE
Next: LPAD



Follow us on Facebook and Twitter for latest update.