There is a database called information_schema
, this 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';
Incidentally, this table stores all the information in a column, not just the comment. This database is also useful for other things, such as getting all the information from the tables of a specific bank:
SELECT * FROM 'information_schema'.'TABLES' a
WHERE a.'TABLE_SCHEMA' = 'seu_banco'