【发布时间】:2019-06-01 15:52:54
【问题描述】:
我正在尝试使用此代码从 mysql 中的表中显示特定数据。我在使用 for 循环之间,但它说 res 或 response 没有定义。我需要在下面的代码中编辑或更改什么?
function lowInventory() {
console.log("View all product that are low in inventory...\n");
for (var i = 0; i < response.length; i++) {
connection.query("SELECT stock_quantity (*) FROM products WHERE stock_quantity < 5", function (err, res) {
if (err) throw err;
//log all results of the SELECT statement
console.table(Response);
connection.end();
});
}
}
我需要它在我的表中显示 node.js 中数量小于 5 的结果。
【问题讨论】: