![](/img/trans.png)
[英]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.