0
我是新來的node.js的投入,我想查詢到另一個查詢的輸入輸出,請幫助的Node.js:如何使用一個查詢的輸出到另一個查詢
pool.getConnection(function(err, connection) {
connection.query("select * from tbl_chat", function(err, rows) {
console.log(rows[0]['from_id']);
var fromid = rows[0]['from_id'];
});
console.log(fromid);//throws ReferenceError: fromid is not defined
console.log(rows[0]['from_id']);// throws ReferenceError: rows is not defined
//I want to use the fromid in the following query
/*connection.query("select * from tbl_chat where from_id=?",[fromid], function(err, rows) {
console.log(rows[0]['from_id']);
});*/
});