show column names in mysql code example
Example 1: mysql get column names from table
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='yourdatabasename'
AND `TABLE_NAME`='yourtablename';
Example 2: get the mysql table columns data type mysql
SHOW COLUMNS FROM mydb.mytable;
Example 3: MySql get fields of table
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table';