When you are creating a field in a MySQL table, there's a 'Comments' box to fill out. How can I access the data in that 'Comments' box with PHP?
Data can be fetched from MySQL tables by executing SQL SELECT statement through PHP function mysql_query. You have several options to fetch data from MySQL. The most frequently used option is to use function mysql_fetch_array(). This function returns row as an associative array, a numeric array, or both.
In MySQL, you can create a SQL comment that spans multiple lines in your SQL statement. For example: SELECT contact_id, last_name, first_name /* * Author: TechOnTheNet.com * Purpose: To show a comment that spans multiple lines in your SQL * statement in MySQL.
Poke around information_schema
.
SELECT table_comment
FROM information_schema.tables
WHERE table_schema = 'myschema' AND table_name = 'mytable'
Use:
SHOW FULL COLUMNS FROM tbl_name
Notice keyword FULL, this is what makes MySQL to include privileges and comments info into the response.
SELECT
COLUMN_COMMENT
FROM
information_schema.COLUMNS
WHERE
TABLE_NAME = 'venue'
Great to use for table column headings or more readable/secure version of real column names. Ex., The column for Venue ID is actually vid_xt
Sample Result from actual query above:
COLUMN_COMMENT
Venue ID
Venue Active
Venue Name
Location Name
Address
Accommodations
Description
Ah, wow. So that's what information_schema database is for. Thank you @Adam Backstrom! Then I believe below should give me the field's comments.
SELECT COLUMN_COMMENT
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'mydatabase' AND TABLE_NAME = 'mytable' AND COLUMN_NAME = 'mycolumn'
Thank you for pointing me to the right direction. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With