我试图在这个函数中调用我的 str 日期变量:
int main(int argc, char **argv)
{
int status = 0;
char query[300], data[15], hora[10];
strDataHora(data, hora);
printf("Date: %s\n", data);
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "mysql_init() failed\n");
exit(1);
}
if (mysql_real_connect(con, "localhost", "root", "ufmg3duc",
"stream_net", 0, NULL, CLIENT_MULTI_STATEMENTS) == NULL)
{
finish_with_error(con);
}
if (mysql_query(con, "SELECT Id FROM audiencia WHERE data LIKE ('%s') AND (hora LIKE ('%:00:%') OR hora LIKE ('%:30:%')) AND hora > '03:01'",data))
{
finish_with_error(con);
}
但我不知道如何在 mysql_query 中调用“日期”:
if (mysql_query(con, "SELECT Id FROM audiencia WHERE data LIKE ('%s') AND (hora LIKE ('%:00:%') OR hora LIKE ('%:30:%')) AND hora > '03:01'",data))
当我的实际日期是 str 变量类型时,如何选择 Id?