Solved

MySQL SELECT COMMENT data in Statement

Posted on 2009-05-11
1
1,121 Views
Last Modified: 2012-05-06
I am dumping some MySQL data and I have used the COMMENT box in phpMyAdmin to give it a nice name. eg. `contact_forname` => 'Contact Forname' and `contact_address_1` => 'Address 1'.

How can I include this data when doing a select??

I am typically doing SELECT * FROM members and the the PHP below.
echo '<table>';

echo '<thead>';

    echo '<tr>';

    foreach($row as $key => $value){

        echo '<th>' . $key . '</th>';  // I WANT THIS TO BE THE CONTENTS OF THE COMMENT BOX!!!

    }

    echo '</tr>';

echo '</thead>';

echo '<tbody>';

foreach($result as $row) {

    echo '<tr>';

    foreach($row as $value){

        echo '<td>' .$value . '</td>';

    }

    echo '</tr>';

}

echo '</tbody>';

echo '</table>';

Open in new window

0
Comment
Question by:stmayes
1 Comment
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24354750
You can't select this directly from the table. The comment is meta data, it is not part of the table. There are however two ways you can use to find it:

You can read it from the information_schema database:

select COLUMN_NAME,COLUMN_COMMENT from information_schema.COLUMNS
where TABLE_SCHEMA='YourDatabase' and TABLE_NAME='members';

Alternatively you can do:

SHOW CREATE TABLE members;

Then you must parse the output you get, and fetch the comments.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL backend - what should be front end? 8 54
Problem with SqlConnection 4 160
MySQL  on Tomcat 8 30
How to import sql database into mysql workbench 18 12
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now