最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - NodeJS - how can get mysql result with executed query? - Stack Overflow

programmeradmin7浏览0评论

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??.

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??.

Share Improve this question asked Dec 3, 2015 at 11:22 Ankur LoriyaAnkur Loriya 3,5348 gold badges34 silver badges60 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8
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);
});

also in preference swith the string query to :

"select id,fname,lname from users where id = '"+req.body.userid+"'" 
发布评论

评论列表(0)

  1. 暂无评论