MySQL UPPER() Function

The UPPER() function in MySQL is used to convert a string to uppercase. It is functionally equivalent to the UCASE() function.


Syntax

UPPER(text)

Parameters

Parameter Description
text Required. The string that you want to convert to uppercase.

Definition and Usage

  • The UPPER() function converts all characters in the specified string to uppercase.

Return Values

  • The function returns the string with all characters converted to uppercase.

Usage Examples

Example 1: Convert a string to uppercase

SELECT UPPER("SQL Tutorial is FUN!") AS UppercaseText;

Output:

UppercaseText
SQL TUTORIAL IS FUN!

Explanation: The entire string is converted to uppercase.

Example 2: Convert the CustomerName column values to uppercase

SELECT UPPER(CustomerName) AS UppercaseCustomerName
FROM Customers;

Output:

UppercaseCustomerName
JOHN DOE
JANE SMITH

Explanation: Each CustomerName in the Customers table is converted to uppercase.


Technical Details

  • Works in: MySQL 4.0 and later.
  • Return Type: String (uppercase version of the original string).

Key Notes

  • The UPPER() function is commonly used to standardize text format, such as when comparing or displaying data consistently in uppercase.
  • It ensures that all alphabetic characters in the string are converted to uppercase, leaving other characters unchanged.
  • UPPER() and UCASE() are interchangeable functions.

Was this article helpful?