
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What MySQL functions can we use to change the character case of a string?
We can use LCASE() and LOWER() functions for changing the character case of a string to lower case and UCASE() and UPPER() functions for changing the character case of a string to upper case.
Example
mysql> Select LCASE('NEW DELHI'); +--------------------+ | LCASE('NEW DELHI') | +--------------------+ | new delhi | +--------------------+ 1 row in set (0.00 sec) mysql> Select LOWER('NEW DELHI'); +--------------------+ | LOWER('NEW DELHI') | +--------------------+ | new delhi | +--------------------+ 1 row in set (0.00 sec) mysql> Select UCASE('new delhi'); +--------------------+ | UCASE('new delhi') | +--------------------+ | NEW DELHI | +--------------------+ 1 row in set (0.00 sec) mysql> Select UPPER('new delhi'); +--------------------+ | UPPER('new delhi') | +--------------------+ | NEW DELHI | +--------------------+ 1 row in set (0.00 sec)
We can also use these functions with the columns of a table. For example, suppose we want to change the character case of the values in a column in the output then following query on table ‘Student’ can demonstrate it −
mysql> Select Name, UCASE(Name) from student; +---------+-------------+ | Name | UCASE(Name) | +---------+-------------+ | Gaurav | GAURAV | | Aarav | AARAV | | Harshit | HARSHIT | | Gaurav | GAURAV | | Yashraj | YASHRAJ | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, LCASE(Name) from student; +---------+-------------+ | Name | LCASE(Name) | +---------+-------------+ | Gaurav | gaurav | | Aarav | aarav | | Harshit | harshit | | Gaurav | gaurav | | Yashraj | yashraj | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, UPPER(Name) from student; +---------+-------------+ | Name | UPPER(Name) | +---------+-------------+ | Gaurav | GAURAV | | Aarav | AARAV | | Harshit | HARSHIT | | Gaurav | GAURAV | | Yashraj | YASHRAJ | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, LOWER(Name) from student; +---------+-------------+ | Name | LOWER(Name) | +---------+-------------+ | Gaurav | gaurav | | Aarav | aarav | | Harshit | harshit | | Gaurav | gaurav | | Yashraj | yashraj | +---------+-------------+ 5 rows in set (0.00 sec)
- Related Articles
- Can we use WHERE clause inside MySQL CASE statement?
- How can we use the output of LTRIM() and RTRIM() functions to update MySQL table?
- How can we stuff a string with another one using MySQL functions?
- How can we use MySQL LPAD() and RPAD() functions in the same query for padding the string to both sides, left and right, of the original string?
- Why should we use MySQL CASE Statement?
- How can we use LPAD() or RPAD() functions with the values in the column of a MySQL table?
- How can we change the name of a MySQL table?
- Can we use ADD and CHANGE with ALTER Statement in MySQL?
- How can we combine functions in MySQL?
- What is a typical use case for JavaScript anonymous functions?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- In MySQL, how can we use FROM_UNIXTIME() function with format string?
- What are MySQL stored functions and how can we create them?
- How can we check the default character sets of a particular MySQL database?
- In MySQL, how can we get the number code of a particular character?

Advertisements