- 论坛徽章:
- 0
|
MySQL统计一个表的问题,后出错
MYSQL_ROW myRow;
MYSQL_RES *myRes;
char sql[1024];
int res = -1;
//统计数据
sprintf(sql,"SELECT SUM(all_1), SUM(all_2), SUM(all_3), SUM(all_4), SUM(all_5), SUM(all_6), SUM(all) FROM myData ");//统计全部
if(mysql_query(&m_MySql,sql) != 0)
{
printf("SELECT ALLACCOUNT Error: %s\n",mysql_error(&m_MySql));
syslog(LOG_ERR, "SELECT ALLACCOUNT Error: %s\n",mysql_error(&m_MySql));
return -1;
}
myRes = mysql_store_result(&m_MySql);
if(myRes == NULL)
{
printf("Sum Check Out Account Error! %d\n",iCompID);
res = -1;
}
printf("MySqlSumCheckOutAccount 2\n");
//结果
if((myRow = mysql_fetch_row(myRes)))
{
*piChipinCent = atoi(myRow[2]);
*piUpCent = atoi(myRow[3]);
*piUpVipCent = atoi(myRow[4]);
*piDownCent = atoi(myRow[5]);
*piWinCent = atoi(myRow[6]);
*piLossCent = atoi(myRow[7]);
*piCent = atoi(myRow[8]);
res = 1;
}
//到这里都正常
mysql_free_result(myRes);//这里就出错是什么问题。
//显示段错误 |
|