I am trying to run an sql query using Node.js, using a prepared statement, as follows:
sql = "UPDATE users SET ? WHERE user_id = ?"
con.query(sql, {current_quiz: quizId, user_id: selected[0]},
function(result, err) {
if(err) throw err
console.log(result)
})
However the result returns an error, because the code is inserting an extra column into the query:
sql: 'UPDATE users SET `current_quiz` = 1, `user_id` = \'1\' WHERE user_id = ?'
What can I do to ensure that selected[0] is used by the user_id= part of the statement, rather than added as an extra column/value pair?