'how to get only name of columns in mysql table?
i saw this post MySQL query to get column names?
i try to use this code `table name` or DESCRIBE `table name` or SHOW COLUMNS FROM `table name`
but return me also a datatype and more in this mode
id int NO auto_increment
i want only a name id is possible have it ?? thanks somtime is possible bypass qualitystandard ?? please
Solution 1:[1]
use the tables from information_schema to get the meta data of your table:
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tbl_name'
For more information see https://docs.oracle.com/cd/E19078-01/mysql/mysql-refman-5.0/information-schema.html#columns-table
Solution 2:[2]
If you don't like the default output of the SHOW commands, you can get anything you want from the INFORMATION_SCHEMA tables (which is where the SHOW commands get their data too).
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jens |
| Solution 2 | Bill Karwin |
