This article will guide you on how to use the UPPER() function to convert a given string to all upper case alphabets.
The UPPER() function returns a given string, an expression, or values in a column in all uppercase letters. The syntax of the function is illustrated below:
It accepts input as a string and returns text in uppercase letters.
💡 Special Case:
- If characters in the input are not of type string, they remain unaffected by the UPPER() function.
- We support Unicode for the UPPER() function.
#Case 1: Basic UPPER() function
The following basic query converts the given string in all uppercase alphabets:
The final output will be as follows:
#Case 2: UPPER() function using columns and CONCAT() function
Let’s see how the UPPER() function works using an example with columns. We have a table named personal_details containing employee's id, first_name, last_name, and gender of a retail store:
The above query will show the following table:
Let’s assume that:
- We want to convert employees' first and last names with id numbers 1, 3, and 5 to all uppercase letters.
- Then, combine them using the CONCAT() function into one full_name column in uppercase.
It can be done using the following query:
The output displays the first and last names of employees with the specified ids in uppercase letters: