我是NodeJS的新手mysql(npm install mysql)。
当我尝试执行像
这样的查询时connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
**here I want query which above executed**
});
我想在执行的回调函数中查询。
我怎样才能得到它?。
答案 0 :(得分:4)
var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
console.log(c.sql)
});
答案 1 :(得分:1)
connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
res.send(rows);
});
还优先将字符串查询转换为:
"select id,fname,lname from users where id = '"+req.body.userid+"'"