Is there any way to select a comment on a column in a mysql?
Moderator: General Moderators
Is there any way to select a comment on a column in a mysql?
Is there any way to select a comment on a column in a mysql query?Can it be done (and used
with php)?Or is there any built-in php functions for doing it?
Regards,
Sobha
with php)?Or is there any built-in php functions for doing it?
Regards,
Sobha
Re: Is there any way to select a comment on a column in a mysql?
You can treat the results of
as if it were a regular SELECT query...
Code: Select all
SHOW FULL COLUMNS FOR tableRe: Is there any way to select a comment on a column in a mysql?
Thanks for your reply.Is there any way to display only the comments in all the column fileds rather than all the column fields in mysql using PHP?Or is there any special functions in php to do that ?
To display column field we use mysql_field_name().Similarly is there any php functions to display comment in column field of mysql
To display column field we use mysql_field_name().Similarly is there any php functions to display comment in column field of mysql
Re: Is there any way to select a comment on a column in a mysql?
I can't seem to find the exact solution (for teh query part) but here's a way you could display only the columns and their comments:
The array call is case-sensitive, that's why I put an uppercase F to $r['Field'] and C to Comment
Code: Select all
$sql = mysql_query("SHOW FULL COLUMNS FROM table_name_here",$link);
while($r=mysql_fetch_assoc($sql)) {
if(!empty($r['Comment'])) {
echo "Table ".$r['Field']." has the following comment: ".$r['Comment']."<br />";
}
}
The array call is case-sensitive, that's why I put an uppercase F to $r['Field'] and C to Comment
Re: Is there any way to select a comment on a column in a mysql?
Thanks for ur reply.I didnt understand $link.What is it supposed to be?
Re: Is there any way to select a comment on a column in a mysql?
Did u mean $link = mysql_connect($dbs,$dbu,$dbpw)
Re: Is there any way to select a comment on a column in a mysql?
Yeh, $link referred to the db connection, sorry I didn't specify.
I checked the MySQL manual didn't find any direct query that would specifically retrieve the comment rows, also because to get the COMMENT field/column, you need to supply the FULL keyword. So I guess you couldn't really do otherwise than grab all the data as an array and loop to see the occurences in each table instance.
Did it work out on your side?
I checked the MySQL manual didn't find any direct query that would specifically retrieve the comment rows, also because to get the COMMENT field/column, you need to supply the FULL keyword. So I guess you couldn't really do otherwise than grab all the data as an array and loop to see the occurences in each table instance.
Did it work out on your side?
Re: Is there any way to select a comment on a column in a mysql?
Thanks for your effort for going thru the MYSQL manual.No it is not working.
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource.
what should i use instead of mysql_fetch_assoc()?
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource.
what should i use instead of mysql_fetch_assoc()?
Re: Is there any way to select a comment on a column in a mysql?
Alright, then it must be a variable that hasn't been changed correctly, cuz mysql_fetch_assoc() should work and usually that kind of error is given when example your database connection is not correctly associated with the mysql_fetch_assoc() function.
Check below:
1 - In the above code, I put the variable $sql in red. Are you sure they correspond in yours? Meaning, if you named your query $some_query_name, have you done the same in mysql_fetch_assoc($some_query_name)
2 - Change the variable $link (from my code) to your database connection variable. So, if you connect using $some_variable like this: $some_variable = mysql_connect($host, $user, $pwd), have you changed $link to your $some_variable ?
If these don't resolve the situation tell me.
UPDATE : And of course, make sure that your_table_name_here (that I called table_name_here in my first post) is replaced by the name of your table.
Check below:
Code: Select all
[color=#DF1B1B]$sql[/color] = mysql_query("SHOW FULL COLUMNS FROM your_table_name_here ",[b]$link[/b]);
while($r=mysql_fetch_assoc([color=#DF1B1B]$sql[/color])) {
//..
}
2 - Change the variable $link (from my code) to your database connection variable. So, if you connect using $some_variable like this: $some_variable = mysql_connect($host, $user, $pwd), have you changed $link to your $some_variable ?
If these don't resolve the situation tell me.
UPDATE : And of course, make sure that your_table_name_here (that I called table_name_here in my first post) is replaced by the name of your table.
Last edited by neuroxik on Wed Aug 12, 2009 12:38 am, edited 2 times in total.
Re: Is there any way to select a comment on a column in a mysql?
It worked now for me .Thanks for your reply.
select comment on a column from two tables in a mysql?
How to select comment on a column from two tables in a mysql?
I tried this.But it shows error.What is the syntax to be used?
SHOW FULL COLUMNS FROM table1 , table2;
I tried this.But it shows error.What is the syntax to be used?
SHOW FULL COLUMNS FROM table1 , table2;
Re: Is there any way to select a comment on a column in a mysql?
It depends on what you want, because you can use INNER JOIN, LEFT JOIN or RIGHT JOIN.
Example:
SHOW FULL COLUMNS FROM table1 INNER JOIN table2
I've never done this with SHOW, only on SELECTs, so I'm not sure but usually a select joining two tables could look like this:
SELECT * FROM table1 INNER JOIN table2 on table1.column_name_here = table2.column_name_here
If I have time, I'll test it with SHOW FULL.
Example:
SHOW FULL COLUMNS FROM table1 INNER JOIN table2
I've never done this with SHOW, only on SELECTs, so I'm not sure but usually a select joining two tables could look like this:
SELECT * FROM table1 INNER JOIN table2 on table1.column_name_here = table2.column_name_here
If I have time, I'll test it with SHOW FULL.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Is there any way to select a comment on a column in a mysql?
Code: Select all
SELECT * FROM user_col_comments WHERE table_name = 'your_table_name'Re: Is there any way to select a comment on a column in a mysql?
SHOW FULL COLUMNS FROM table1 INNER JOIN table2 shows sql syntax error.