Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MySQL SELECT COMMENT data in Statement

Posted on 2009-05-11
1
1,126 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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