Reputation: 3534
I am new in NodeJS with mysql (npm install mysql).
When I try to execute query like
connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
**here I want query which above executed**
});
I want query in callback function which executed.
How can I get it??.
Upvotes: 1
Views: 4096
Reputation: 485
var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
console.log(c.sql)
});
Upvotes: 8
Reputation: 1169
connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
res.send(rows);
});
also in preference swith the string query to :
"select id,fname,lname from users where id = '"+req.body.userid+"'"
Upvotes: 0