
- 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
How to lowercase the entire string keeping the first letter in uppercase with MySQL?
Let us first create a table −
mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (1.32 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('JOhn'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('CHRIS'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('DAVID'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('RObert'); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+--------+ | Name | +--------+ | JOhn | | CHRIS | | DAVID | | RObert | +--------+ 4 rows in set (0.00 sec)
Following is the query to lowercase the entire string keeping the first letter in uppercase in MySQL −
mysql> update DemoTable -> set Name= CONCAT(UCASE(LEFT(Name, 1)), LCASE(SUBSTRING(Name, 2))); Query OK, 4 rows affected (0.30 sec) Rows matched: 4 Changed: 4 Warnings: 0
Let us check all records from the table once again.
mysql> select *from DemoTable;
Output
+--------+ | Name | +--------+ | John | | Chris | | David | | Robert | +--------+ 4 rows in set (0.00 sec)
- Related Articles
- MySQL SELECT to skip first N results?\n
- MySQL query to get the highest value from a single row with multiple columns\n\n\n\n\n\n\n\n\n\n
- How to test if a letter in a string is uppercase or lowercase using javascript?
- Make first letter of a string uppercase in JavaScript?
- How to match any one uppercase character in python using Regular Expression?\n\n
- How to shift each letter in the given string N places down in the alphabet in JavaScript?
- First uppercase letter in a string (Iterative and Recursive) in C++
- How to extract the first n characters from a string using Java?
- Convert string to lowercase or uppercase in Arduino
- How to convert lowercase letters in string to uppercase in Python?
- Return the first n letters of a column in MySQL
- How to get first N characters from a MySQL column?
- JavaScript - Remove first n characters from string
- How to create half of the string in uppercase and the other half in lowercase?
- How to work with array variable in MySQL?\n

Advertisements