Query () function problem in felixge/node-mysql

  node.js, question

I now have a function to write data, but I need to look up the data from another table before writing. Then I will use it twice in a function inside
However, if the. query () function does not seem to be blocked, the second. query () function will be executed before the first. query () returns.

Do you want to know what is the solution? Thank you!

The second query is written in the callback function of the first query.

connection.query(sql1,function(err, result1){
 connection.query(sql2,function(err, result2){