Returns the value of a specified field in the current record. An overloaded version that accepts a column name as input is available, but not as efficient.


field_value = dbQueryGetField(qid, idx_or_name)
  • qid (scalar) – query number.

  • idx_or_name (scalar or string) – index or name of the field whose value should be returned.


Specifying a string name may result in much slower performance than a numeric index. Use with caution.


The fields are numbered from left to right using the text of the SELECT statement, e.g. in

// Execute query
qid = dbExecQuery(db_id, "SELECT forename, surname FROM people");

do while dbQuerySeekNext(qid);
   // Using field index
   forename = dbQueryGetField(qid, 1);

   // Using field index
   surname = dbQueryGetField(qid, 2);

   // Using field name
   forename = dbQueryGetField(qid, "forename");

   // Using field name
   surname = dbQueryGetField(qid, "surname");

Field 1 is forename and field 2 is surname. Using SELECT * is not recommended because the order of the fields in the query is undefined.