Feynman137
Coder
This may seem like a pretty basic one but I am executing the query:
and seeing the following from
-->
How can I make a variable named command equal to 1 from this?
Below is the full section, but I am hoping that when I execute console.log(command) I just see 1 but this is not the case.
Code:
var sql = 'SELECT command FROM motoron2 ORDER BY id DESC LIMIT 1';
Code:
console.log(result)
Code:
[ RowDataPacket { command: 1 } ]
How can I make a variable named command equal to 1 from this?
Below is the full section, but I am hoping that when I execute console.log(command) I just see 1 but this is not the case.
Code:
var sql = 'SELECT command FROM motoron2 ORDER BY id DESC LIMIT 1';
con.query(sql, function (err, result) {
if (err) {
throw err;
}
// access result inside the callback
console.log(result);
var command = result[0];
});
Last edited: