繁体   English   中英

NodeJS-如何通过执行的查询获取mysql结果?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM