Saturday, 20 May 2017

Multiple SQL WHERE query in node.JS using Array

I need simply code in my SQL query. Using SET is possible to do with an Array, but when i do with WHERE query, there's any error. Is it possible using WHERE in arary? I've been read documentation but i can't found it for MULTIPLES WHERE query

Example :

var values = {
  date : "2017-03-03 12:11:09",
  ticket_id : "12212",
  status : "Done"
}

var condition = {
  id : 21,
  status : "Pending"
}

pool.query("UPDATE queue SET ? WHERE ??", [values, condition], function(err, results){
   if(err){
      console.log(err)
      return
    }
    console.log(results)
})

And i found some error

{ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `status` = 'Pending'' at line 1

Thank you,



via Ade Firman Fauzi

No comments:

Post a Comment