Solved

MySQL SELECT COMMENT data in Statement

Posted on 2009-05-11
1
1,119 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
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

10 Experts available now in Live!

Get 1:1 Help Now