Home  >  Article  >  Database  >  How to convert value to uppercase in mysql

How to convert value to uppercase in mysql

青灯夜游
青灯夜游Original
2021-12-07 10:32:187337browse

In mysql, you can use the UPPER() function to convert values ​​to uppercase. The function of this function is to convert all alphabetic characters in the string to uppercase. The syntax is "SELECT UPPER(str);".

How to convert value to uppercase in mysql

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

In mysql, you can use the uppercase letter conversion function UPPER() to convert values ​​to uppercase.

UPPER(str) can convert all alphabetic characters in the string str to uppercase.

Syntax:

SELECT UPPER(str);
  • str: ​​Required. The string to be converted

[Example] Use the UPPER function to convert all alphabetic characters in the string to uppercase

mysql> SELECT UPPER('green'),UPPER('Green');
+----------------+----------------+
| UPPER('green') | UPPER('Green') |
+----------------+----------------+
| GREEN          | GREEN          |
+----------------+----------------+
1 row in set (0.03 sec)

As you can see from the result, all the original letters If the characters are lowercase, all are converted to uppercase, such as "green", and the result is "GREEN" after conversion; if the string is a mixture of uppercase and lowercase letters, the uppercase remains unchanged, and the lowercase letters are converted to uppercase letters, such as "Green", and after conversion it is " GREEN".

[Related recommendations: mysql video tutorial]

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

Statement:
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