
- 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
MySQL Query to change lower case to upper case?
You can use in-built function UPPER() from MySQL to change a lower case to upper case. The syntax is as follows with select statement.
SELECT UPPER(‘yourStringValue’);
The following is an example showing string in lower case −
mysql> select upper('john');
Here is the output displaying string in upper case −
+---------------+ | upper('john') | +---------------+ | JOHN | +---------------+ 1 row in set (0.00 sec)
If you already have a table with a lower case value, then you can use the UPPER() function with update command. The syntax is as follows −
UPDATE yourTableName set yourColumnName = UPPER(yourColumnName);
To understand the above concept, let us first create a table and insert string values in lowercase. The following is the query to create a table −
mysql> create table UpperTableDemo −> ( −> BookName longtext −> ); Query OK, 0 rows affected (0.70 sec)
Insert some records in the table using INSERT command. The query is as follows −
mysql> insert into UpperTableDemo values('introduction to c'); Query OK, 1 row affected (0.13 sec) mysql> insert into UpperTableDemo values('introduction to java'); Query OK, 1 row affected (0.18 sec) mysql> insert into UpperTableDemo values('introduction to python'); Query OK, 1 row affected (0.11 sec) mysql> insert into UpperTableDemo values('introduction to c#'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from UpperTableDemo;
The following is the output −
+------------------------+ | BookName | +------------------------+ | introduction to c | | introduction to java | | introduction to python | | introduction to c# | +------------------------+ 4 rows in set (0.00 sec)
The following is the query to change the lower case to upper case −
mysql> update UpperTableDemo set BookName = upper(BookName); Query OK, 4 rows affected (0.16 sec) Rows matched: 4 Changed: 4 Warnings: 0
Display all records again with updated value. The query is as follows −
mysql> select *from UpperTableDemo;
The following is the output −
+------------------------+ | BookName | +------------------------+ | INTRODUCTION TO C | | INTRODUCTION TO JAVA | | INTRODUCTION TO PYTHON | | INTRODUCTION TO C# | +------------------------+ 4 rows in set (0.00 sec)
- Related Articles
- How to convert Lower case to Upper Case using C#?
- How to convert Upper case to Lower Case using C#?
- How to change the case to UPPER/lower/Proper in an Excel Sheet?
- Python regex to find sequences of one upper case letter followed by lower case letters
- Java Program to check whether the entered character a digit, white space, lower case or upper case character
- Convert mixed case string to lower case in JavaScript
- Java program to count upper and lower case characters in a given string
- Python program to count upper and lower case characters without using inbuilt functions
- C# program to count upper and lower case characters in a given string
- Make all column names lower case in MySQL with a single query
- C program to convert upper case to lower and vice versa by using string concepts
- Converting to upper case in Java.
- Lower case column names with MySQL SELECT?
- Java String to Lower Case example.
- Rename all tables and columns to lower case in MySQL?
