In MySQL, you can use the UPPER() function to convert any lowercase characters to uppercase. Alternatively, you can use the UCASE() function, which is a synonym for UPPER().
The syntax goes like this:
UPPER(str)
Or…
UCASE(str)
Where
str
is the string you want converted to uppercase.Example
Here’s an example:
SELECT UPPER('homer');
Result:
+----------------+ | UPPER('homer') | +----------------+ | HOMER | +----------------+
If the string already contains any uppercase characters, then they will remain uppercase.
Example:
SELECT UPPER('Homer');
Result:
+----------------+ | UPPER('Homer') | +----------------+ | HOMER | +----------------+
Database Example
Here’s an example of selecting data from a database and converting it to uppercase:
USE Music; SELECT ArtistName AS Original, UPPER(ArtistName) AS Uppercase FROM Artists LIMIT 5;
Result:
+------------------+------------------+ | Original | Uppercase | +------------------+------------------+ | Iron Maiden | IRON MAIDEN | | AC/DC | AC/DC | | Allan Holdsworth | ALLAN HOLDSWORTH | | Buddy Rich | BUDDY RICH | | Devin Townsend | DEVIN TOWNSEND | +------------------+------------------+
0 comments:
Post a Comment