这是一个在C ++中使用数据库(MySQL)的程序。
要检查if语句中是否存在学生ID,
我想从id ='%d';
的点使用select *但是,您不能将数据库命令放在if
语句中。我该怎么办?
void sortSelect(MYSQL *con) {
MYSQL * connection = NULL, conn;
MYSQL_RES * sql_result;
MYSQL_ROW sql_row;
int hakbun, no, point, field, j;
char query[1024];
cout << " Enter Student ID > ";
sprintf_s(query, "select * from point where hakbun='%d';", hakbun);
cin >> hakbun;
cout << endl;
/* if ( ) { // Question 4
}
else { // Omitted
}
*/
}