Use double percent signs to escape the percent signs in the string, and remove the extra apostrophes around the value:
sprintf(query, "UPDATE Vote "
"SET choice = '%s' "
"WHERE choice LIKE '%%%s%%'", newVote, originalVoteContains);
문제
I'm trying to search and update columns in my database by the value of a string variable:
sprintf(query, "UPDATE Vote "
"SET choice = '%s' "
"WHERE choice LIKE '%'%s'%'", newVote, originalVoteContains);
how can I use a variable of type string in the LIKE operator?
해결책
Use double percent signs to escape the percent signs in the string, and remove the extra apostrophes around the value:
sprintf(query, "UPDATE Vote "
"SET choice = '%s' "
"WHERE choice LIKE '%%%s%%'", newVote, originalVoteContains);