MySQL UCASE() Function
The MySQL UCASE() function converts all characters of the given string to uppercase. Any symbol, space, or number in the string is ignored while applying this function. Only alphabet are converted.
This function converts the characters using the current character mapping set, which is latin1, by default.
The UCASE() function is a synonym for the UPPER() function.
Syntax
UCASE(string)
Parameters
string |
Required. Specify the string to convert to uppercase. |
Return Value
Returns the string with all characters of the specified string to uppercase.
Example 1:
The example below shows the usage of UCASE() function.
mysql> SELECT UCASE('Learning SQL is FUN!'); Result: 'LEARNING SQL IS FUN!' mysql> SELECT UCASE(' SQL Tutorial '); Result: ' SQL TUTORIAL '
Example 2:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age | Salary |
---|---|---|---|---|
1 | John | London | 25 | 3000 |
2 | Marry | New York | 24 | 2750 |
3 | Jo | Paris | 27 | 2800 |
4 | Kim | Amsterdam | 30 | 3100 |
5 | Ramesh | New Delhi | 28 | 3000 |
6 | Huang | Beijing | 28 | 2800 |
The query given below is used to convert of column City to uppercase.
SELECT *, UCASE(City) AS City_Uppercase FROM Employee;
The query will produce the following result:
EmpID | Name | City | Age | City_Uppercase |
---|---|---|---|---|
1 | John | London | 25 | LONDON |
2 | Marry | New York | 24 | NEW YORK |
3 | Jo | Paris | 27 | PARIS |
4 | Kim | Amsterdam | 30 | AMSTERDAM |
5 | Ramesh | New Delhi | 28 | NEW DELHI |
6 | Huang | Beijing | 28 | BEIJING |
❮ MySQL Functions