Skip to content

Instantly share code, notes, and snippets.

@nasirkhan
Last active August 29, 2015 14:01
Show Gist options
  • Save nasirkhan/9ff1848a215d61880463 to your computer and use it in GitHub Desktop.
Save nasirkhan/9ff1848a215d61880463 to your computer and use it in GitHub Desktop.
Get all the column names of a MySQL database table
/*
* MY_DATABASE_NAME will be replaced by the name of your database
* MY_TABLE_NAME will be repaced by the name of your database table
*/
SELECT
`COLUMN_NAME`
FROM
`INFORMATION_SCHEMA`.`COLUMNS`
WHERE
`TABLE_SCHEMA` = 'MY_DATABASE_NAME'
AND `TABLE_NAME` = 'MY_TABLE_NAME';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment