There is a database called information_schema
, that database is responsible for storing the structures of all databases.
To get the comment from a column you can select the table COLUMNS
:
SELECT a.`COLUMN_COMMENT`
FROM `information_schema`.`COLUMNS` a
WHERE a.`TABLE_SCHEMA` = 'seu_banco' AND a.`TABLE_NAME` = 'sua_tabela' AND a.`COLUMN_NAME` = 'sua_coluna';
In fact, this table stores all the information in a column, not just the comment. This database is also useful for other things, such as taking all information from tables in a specific database:
SELECT * FROM `information_schema`.`TABLES` a
WHERE a.`TABLE_SCHEMA` = 'seu_banco'
Look at that answer: Link
– rbz