
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Exclude Certain Columns from SHOW COLUMNS in MySQL
Let us first create a demo table
mysql> create table excludeCertainColumnsDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int, -> StudentMarks int, -> StudentAddress varchar(200) -> ); Query OK, 0 rows affected (0.50 sec)
Now you can check the description of table with the help of desc command. The query is as follows −
mysql> desc excludeCertainColumnsDemo;
The following is the output
+----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(100) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | | StudentMarks | int(11) | YES | | NULL | | | StudentAddress | varchar(200) | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec)
Here is the query to exclude certain columns from SHOW COLUMNS. You need to exclude the column 'StudentAge' and 'StudentMarks'. The query is as follows −
mysql> SHOW COLUMNS FROM excludeCertainColumnsDemo WHERE Field NOT IN ('StudentAge', 'StudentMarks');
The following is the output
+----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(100) | YES | | NULL | | | StudentAddress | varchar(200) | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
Advertisements