Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL UCASE() function

UCASE() function

MySQL UCASE() coverts all the characters of a string to uppercase. The UCASE() is a synonym of UPPER()

Syntax:

UCASE (str)

The above function is a synonym for UPPER().

Syntax Diagram:

MySQL UCASE() Function - Syntax Diagram

MySQL Version: 5.6

Video Presentation:

Example: MySQL UCASE() function

The following MySQL statement returns all the characters in the string to uppercase.

Code:

SELECT UCASE('myteststring');

Sample Output:

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

MySQL: Capitalize first letter of a string

We have a table called test1 with following records :

mysql> SELECT * FROM test1;
+-----------+
| test_char |
+-----------+
| abcd      |
| WxyZ      |
| scott     |
| ROBIN     |
+-----------+
4 rows in set (0.00 sec)

Now we want to update the above data where the first character will be in upper case i.e. 'abcd' will be 'Abcd', 'WxyZ' will be 'WxyZ' and so on. See the following MySQL statement:

mysql> UPDATE test1 SET test_char = CONCAT(UCASE(LEFT(test_char, 1)), SUBSTRING(test_char, 2));
Query OK, 2 rows affected (0.03 sec)
Rows matched: 4  Changed: 2  Warnings: 0

mysql> SELECT * FROM test1;
+-----------+
| test_char |
+-----------+
| Abcd      |
| WxyZ      |
| Scott     |
| ROBIN     |
+-----------+
4 rows in set (0.00 sec)

Online Practice Editor:


All String Functions

MySQL String Functions, slide presentation

Previous: TRIM
Next: UNHEX