[英]NodeJS MySQL How to get the result outside of the query function
[英]NodeJS - how can get mysql result with executed query?
我是使用MySQL的 NodeJS的新用户(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**
});
我想查询执行的回调函数。
我怎么才能得到它??。
var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) {
console.log(c.sql)
});
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+"'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.