MySQL 5.7 C API Developer Guide / ... / C API Basic Interface / C API Basic Function Descriptions / mysql_num_rows()
my_ulonglongmysql_num_rows(MYSQL_RES *result)Returns the number of rows in the result set.
The use ofmysql_num_rows() depends on whether you usemysql_store_result() ormysql_use_result() to return the result set. If you usemysql_store_result(),mysql_num_rows() may be called immediately. If you usemysql_use_result(),mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved.
mysql_num_rows() is intended for use with statements that return a result set, such asSELECT. For statements such asINSERT,UPDATE, orDELETE, the number of affected rows can be obtained withmysql_affected_rows().