mysql_fetch_field()
MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)
This function returns a MYSQL_FIELD
structure that provides information on a given field of a results set.
If you use it in conjunction with a loop statement, you can extract
information on each field. Here is an example:
...
MYSQL_FIELD *field;
...
mysql_query(mysql, "SELECT * FROM clients LIMIT 1");
result = mysql_store_result(mysql);
while((field = mysql_fetch_field(result)) != NULL)
{ printf("%s \n", field->name); }
...The wildcard in the SELECT statement selects
all columns in the table. The loop therefore lists the name of each
column. The other possibilities are field->table
for the table name and field->def for the
default value of the column.