Home > Database > Mysql Tutorial > body text

How to convert string to lowercase in mysql

青灯夜游
Release: 2021-12-31 17:09:03
Original
7790 people have browsed it

Mysql method to convert a string to lowercase: 1. Use the LOWER() function, the syntax "SELECT LOWER(str) [FROM data table name];"; 2. Use the LCASE() function, the syntax " SELECT LCASE(str) [FROM data table name];".

How to convert string to lowercase in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

mysql converts strings to lowercase

1. Use the LOWER() function

The alphabetic lowercase conversion function LOWER(str) can convert all alphabetic characters in the string to lowercase.

SELECT LOWER(column_name) [FROM table_name];
Copy after login

Example 1: Use the LOWER function to convert all alphabetic characters in the string to lowercase

mysql> SELECT LOWER('BLUE'),LOWER('Blue');
+---------------+---------------+
| LOWER('BLUE') | LOWER('Blue') |
+---------------+---------------+
| blue          | blue          |
+---------------+---------------+
1 row in set (0.03 sec)
Copy after login

As you can see from the results, all the letters that were originally uppercase are converted to lowercase, such as "BLUE", after conversion, becomes "blue"; a string with mixed uppercase and lowercase letters, the lowercase remains unchanged, and the uppercase letters are converted to lowercase letters, such as "Blue", after conversion, it becomes "bule".

Example 2: Convert the text in "CustomerName" to lowercase

SELECT LCASE(CustomerName) AS LowercaseCustomerName
FROM Customers;
Copy after login

2. Use the LCASE() function

LCASE( ) is a synonym for LOWER().

LCASE() function converts the field value to lowercase.

SELECT LCASE(str) [FROM table_name];
Copy after login

Example: Convert the text in "CustomerName" to lowercase

SELECT LCASE(CustomerName) AS LowercaseCustomerName
FROM Customers;
Copy after login

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to convert string to lowercase in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!