Reputation: 55
I'm getting an error about Unknown column 'CR0001' in 'where clause'
and I don't know why because the where clause it's about id_scooter column not cr0001. Here is my code
var update = "UPDATE coordonate SET ? WHERE id_scooter=CR0001 ";
con.query(update, { id_scooter: array[0], lat: array[3], longi: array[4], alt: array[5], ip: rinfo.address, port: rinfo.port, speed: array[6], nr_satelites: array[2], battery_lvl: array[1] }, function (err, result) {
if (err) throw err;
console.log("Number of records inserted: " + result.affectedRows);
});
Upvotes: 0
Views: 38
Reputation: 1423
CR0001 is a string, not an integer. Therefore it has to be in quotes like this:
var update = "UPDATE coordonate SET ? WHERE id_scooter='CR0001' ";
If you want custom parameters in your ? question marks, you can pass array as second argument:
var update = "UPDATE coordonate SET ?=? WHERE id_scooter=? ";
con.query(update, [col, val, idscooter], function (err, result) {
if (err) throw err;
console.log("Number of records inserted: " + result.affectedRows);
});
(Replace col, val, idscooter with correct data)
Upvotes: 1