- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Advertisements