UPPER()
Converts all characters in a string to uppercase.
Description
UPPER converts every letter in a string to its uppercase form. It's the
mirror image of LOWER, and it's often used for display formatting or for
normalizing text before comparing it.
Syntax
UPPER(string)Parameters
| Name | Description | Optional |
|---|---|---|
| string | The text value or column to convert. Non-letter characters (numbers, punctuation) are left unchanged. | No |
Return Type
UPPER returns a VARCHAR (text) value.
Examples
Store (Customers/Orders/Products)
Loading database engine...
Store (Customers/Orders/Products)
Loading database engine...
UPPER is handy for consistent grouping
If the city column has inconsistent capitalization across rows (like
'boston' and 'Boston'), grouping by UPPER(city) instead of city
merges them into one consistent bucket.
Common Mistakes
- Expecting
UPPERto permanently change stored data. It only affects the value in the query result, not what's saved in thecustomerstable. - Applying
UPPERto non-text data without casting. Numeric or date columns need an explicitCASTto text beforeUPPERwill work on them in most databases. - Using
UPPERpurely for display when a case-insensitive comparison operator or collation would be simpler. Sometimes the cleaner fix is a case-insensitiveWHEREclause rather than transforming every value.
Related Functions
See also: LOWER, CONCAT, SUBSTRING.