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 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
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework