Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain column comments from SQL

As you guys propably know, there's the possibility to add a comment to a column in MySQL. Now I was wondering how I could obtain this comment via PHP/MySQL. I was searching the web but I didn't find any solution yet. Do you guys have any idea/solution for this problem?

Greetings!

like image 735
n0pt3x Avatar asked Nov 29 '22 10:11

n0pt3x


2 Answers

SELECT
    COLUMN_COMMENT
FROM
    INFORMATION_SCHEMA.COLUMNS
WHERE
    TABLE_SCHEMA = 'db-name' AND
    TABLE_NAME = 'table-name' AND
    COLUMN_NAME = 'column-name'

http://dev.mysql.com/doc/refman/5.0/en/columns-table.html

like image 200
Hammerite Avatar answered Dec 10 '22 04:12

Hammerite


Just use this SQL:

SHOW FULL COLUMNS FROM myTable

http://dev.mysql.com/doc/refman/5.0/en/show-columns.html

The FULL keyword causes the output to include the column collation and comments, as well as the privileges you have for each column.

like image 20
AlienWebguy Avatar answered Dec 10 '22 04:12

AlienWebguy