1

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

2 Answers 2

8
var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) { console.log(c.sql) }); 
Sign up to request clarification or add additional context in comments.

1 Comment

How I will get the query if I am using promise?
0
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+"'" 

1 Comment

actually, I want query in Call Back function. No I don't want switch param as string query.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.