Documentation Home
MySQL 5.5 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

MySQL 5.5 Reference Manual  /  ...  /  mysql_fetch_field_direct() mysql_fetch_field_direct()

MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *result, unsigned int fieldnr)


Given a field number fieldnr for a column within a result set, returns that column's field definition as a MYSQL_FIELD structure. Use this function to retrieve the definition for an arbitrary column. Specify a value for fieldnr in the range from 0 to mysql_num_fields(result)-1.

Return Values

The MYSQL_FIELD structure for the specified column.



unsigned int num_fields;
unsigned int i;

num_fields = mysql_num_fields(result);
for(i = 0; i < num_fields; i++)
    field = mysql_fetch_field_direct(result, i);
    printf("Field %u is %s\n", i, field->name);

Download this Manual
User Comments
  Posted by Rick Pfahl on September 28, 2005
If you are experiencing problems with mysql_fetch_fields(MYSQL_RES*)
(i.e., mysql_fetch_fields is not returning array of MYSQL_FIELD, but rather a pointer the first field) use mysql_fetch_field_direct(MYSQL_RES*, int) instead.
Sign Up Login You must be logged in to post a comment.