to do this you have to query the db schema. In MySQL, there is a system generated database called information_schema.
from within it, you could run:
SELECT column_name
FROM COLUMNS
WHERE table_name = 'desired_table'
AND table_schema = 'database_name'