
- 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
Lower case column names with MySQL SELECT?
Let us first create a table −
mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserFirstName varchar(20), UserLastName varchar(20), UserAge int, UserCountryName varchar(20) ); Query OK, 0 rows affected (0.27 sec)
Now check the description of table.
mysql> desc DemoTable;
This will produce the following output −
+-----------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+----------------+ | UserId | int(11) | NO | PRI | NULL | auto_increment | | UserFirstName | varchar(20) | YES | | NULL | | | UserLastName | varchar(20) | YES | | NULL | | | UserAge | int(11) | YES | | NULL | | | UserCountryName | varchar(20) | YES | | NULL | | +-----------------+-------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec)
Following is the query to convert case to lower case column names while using SELECT.
mysql> SELECT LOWER(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'DemoTable';
This will produce the following output −
+--------------------+ | LOWER(COLUMN_NAME) | +--------------------+ | userage | | usercountryname | | userfirstname | | userid | | userlastname | +--------------------+ 5 rows in set (0.03 sec)
- Related Articles
- Make all column names lower case in MySQL with a single query
- Select column names containing a string in MySQL?
- How to change column names to capital letters from lower case or vice versa in R?
- Select Statement to retrieve the same first names with similar last name (but different case) using MySQL?
- MySQL Query to change lower case to upper case?
- Set Blank spaces in column names with MySQL?
- How to use special characters in column names with MySQL?
- Are MySQL database and table names case-sensitive?
- MySQL CASE WHEN with SELECT to display odd and even ids?
- Store a variable with the result of a MySQL SELECT CASE?
- MySQL select for exact case sensitive match with hyphen in records
- MySQL - SELECT … WHERE id IN (..) order with particular column?
- Implement case sensitivity in MySQL SELECT statements
- Perform case insensitive SELECT using MySQL IN()?
- MySQL case statement inside a select statement?

Advertisements