Get just the fields names of a table in MySQL

If you do:

describe `table_name`

Mysql will give you table information which will contain field names, their types, etc. What if you want just the field names and nothing else? You can run this query and do just that:

SELECT column_name
FROM INFORMATION_SCHEMA.columns
WHERE table_name = 'tablename'
AND   table_schema = 'dbname';

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *