Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql: Show columns but exclude everything except the field names

Tags:

mysql

I'd like to pull a table's field names from MySql into python, and I know that

'show columns from project' 

will work. And I've read that you can add 'WHERE ...' to restrict it to just certain fields. But I can't find an example of how to return just the names of the columns, and not Type, Key, Null, Extra information.

What is the matching criteria to pull all field names for columns and none of the other description stuff?

like image 208
ChewyChunks Avatar asked Apr 02 '11 21:04

ChewyChunks


People also ask

How do I show all columns except one in MySQL?

The information_schema. COLUMNS table holds all information about the columns in your MySQL tables. To exclude columns, you use the REPLACE() and GROUP_CONCAT() functions to generate the column names you wish to include in your SELECT statement later.

How do I show only columns in MySQL?

Syntax. The following is a syntax to display the column information in a specified table: SHOW [EXTENDED] [FULL] {COLUMNS | FIELDS} {FROM | IN} table_name.

How do I ignore a column in MySQL?

The syntax of the INSERT IGNORE statement is as follows: INSERT IGNORE INTO table(column_list) VALUES( value_list), ( value_list), ... Note that the IGNORE clause is an extension of MySQL to the SQL standard.


1 Answers

SELECT column_name FROM information_schema.columns WHERE  table_name = 'your_table'    AND table_schema = 'database_name' 
like image 148
a_horse_with_no_name Avatar answered Sep 21 '22 11:09

a_horse_with_no_name