
- 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 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)
- Related Articles
- How to select all the column names from a table in Laravel?
- How to retrieve table names from a database in MySQL?
- Select distinct names from two columns in MySQL and display the result in a single column
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- Display month names and year from a column with date records with MySQL
- How to get left substring in MySQL from a column with file path? Display the entire file path string excluding the file name?
- Selecting and displaying only some rows from a column in a MySQL table
- MySQL query to group by names and display the count in a new column
- How to delete a column from a table in MySQL?
- Display specific table names with MySQL LIKE Operator
- What is the syntax in MySQL to get the column names of a table?
- Display only the duplicate column names appearing atleast thrice in MySQL
- Get table column names in alphabetical order in MySQL?
- How to subset a data frame by excluding the column names that are stored in a vector in R?
- Display MySQL Database, Table, and Column Information

Advertisements