w3resource

MySQL UPPER() function

UPPER() function

MySQL UPPER() converts all the characters in a string to uppercase characters.

This function is useful in -

  • Uppercase conversion: It allows you to convert a string to uppercase
  • Case-insensitive comparison: UPPER() can be used for case-insensitive string comparison.
  • Data normalization: UPPER() is often used in data normalization tasks to convert strings to a consistent case.

Syntax:

UPPER (string)

Argument:

Name Description
string A string whose characters are to be converted to uppercase.

Syntax Diagram:

MySQL UPPER() Function - Syntax Diagram

MySQL Version: 8.0

Example : MySQL UPPER() function

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

Code:

SELECT UPPER('myteststring');

Output:

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

Example of MySQL UPPER() function with where clause

The following MySQL statement returns those rows from the publisher table whose publishers are not belonging the country USA. The column pub_name, and values of publisher names in uppercase have been shown in the output.

Code:

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

Sample table: publisher


Output:

mysql> SELECT pub_name,UPPER(pub_name) 
    -> FROM publisher 
    -> WHERE country<>'USA';
+------------------------------+------------------------------+
| pub_name                     | UPPER(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.11 sec)

All String Functions (Slides presentation)

Previous: UNHEX
Next: MySQL Mathematical functions ABS()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/mysql/string-functions/mysql-upper-function.php