【发布时间】:2023-04-07 17:25:01
【问题描述】:
{ 错误:ER_PARSE_ERROR:您的 SQL 语法有错误;查看 与您的 MySQL 服务器版本相对应的手册 在第 1 行的“未定义”附近使用的语法
我尝试在表格列中添加反引号,但没有奏效。
function quantityCheck(ID, itemsPurchased){
connection.query('Select * FROM `products` WHERE `item_id` ' + ID, function(err, res){
if (err){console.log(err)};
if(itemsPurchased <= res[0].stock_quantity){
var total = res[0].price * itemsPurchased;
console.log('Your items are available for final purchase.')
console.log ('Total today for ' + itemsPurchased + ' ' + res[0].product_name + ' is ' + total);
connection.query('UPDATE products SET stock_quantity = stock_quantity -' + itemsPurchased + 'WHERE item_id = ' + ID);
} else {
console.log ('Your purchase could not be processed. We have limited quantities of ' + res[0].product_name);
}
display();
})
我想显示quantityCheck(); connection.query 方法之后的代码。
【问题讨论】: