Show Comment of Fields FROM Mysql Table

Mysql

Mysql Problem Overview


SHOW COLUMNS FROM <tablename> gives all the information of the columns in a table, except Comments.

How to extract Comments information? I know the way to extract the information from INFORMATION SCHEMA, but how to combine the result in a single result set?

Mysql Solutions


Solution 1 - Mysql

You can use the query

SHOW FULL COLUMNS FROM <tablename>

If you don't want to use information_schema.

Solution 2 - Mysql

select `column_name`, `column_type`, `column_default`, `column_comment`
from `information_schema`.`COLUMNS` 
where `table_name` = 'table-name' 
and `table_schema` = 'db-name';

Solution 3 - Mysql

In case you want to get the table comments instead :

SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'my_table' and 
      table_schema = 'my_database'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStarxView Question on Stackoverflow
Solution 1 - MysqlNicola CossuView Answer on Stackoverflow
Solution 2 - MysqlshenyanView Answer on Stackoverflow
Solution 3 - MysqlKingRiderView Answer on Stackoverflow