Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to display the column names from a table excluding some in MySQL?
To exclude some of the column names, use NOT IN.
Let us first create a table −
mysql> create table DemoTable780 ( CustomerId int, CustomerName varchar(100), CustomerAge int, CustomerCountryName varchar(100), isMarried tinyint(1) ); Query OK, 0 rows affected (0.47 sec)
Here is the query to exclude result −
mysql> select group_concat(column_name) from `information_schema`.`COLUMNS` m
where
table_schema = 'web' and
table_name = 'DemoTable780' and
column_name not in ('CustomerId','CustomerCountryName')
group by table_schema,table_name;
This will produce the following output -
+------------------------------------+ | group_concat(column_name) | +------------------------------------+ | CustomerName,CustomerAge,isMarried | +------------------------------------+ 1 row in set (0.01 sec)
Advertisements
