你后边需要一些逻辑来取出结果并释放它。 result_ = mysql_store_result(mysql_); while (row_ = mysql_fetch_row(result_)) { // get the field value if (row_[0]) { std::cout<<"count = "<<row_[0]<<std::endl; // convert it into int cnt = atoi(row_[0]); std::cout<<"cnt value = "<<row_[0]<<std::endl; } } mysql_free_result(result_); 这里有一个更复杂的取多个结果集的例子: http://blog.csdn.net/iihero/article/details/8362269
result_ = mysql_store_result(mysql_);
while (row_ = mysql_fetch_row(result_))
{
// get the field value
if (row_[0])
{
std::cout<<"count = "<<row_[0]<<std::endl;
// convert it into int
cnt = atoi(row_[0]);
std::cout<<"cnt value = "<<row_[0]<<std::endl;
}
}
mysql_free_result(result_); 这里有一个更复杂的取多个结果集的例子:
http://blog.csdn.net/iihero/article/details/8362269
MYSQL_ROW row;
result = mysql_store_result(mysql);
while((row = mysql_fetch_row(result))) //将查询出的结果存入相应对象中
{
strcpy(tabname, row[0]); //若select出的是多个列,那就依次填上row[1],row[2]...
}
mysql_free_result(result); //别忘了free