问题描述
每次客户购买stockQuantity
时,我都希望减少库存数量(main_product_info
。
我正在尝试使用以下代码,但似乎无法正常工作,我是DB
的新手,所以不确定我是否使用正确的代码。
也如下面的代码所示,我直接针对quantity
更新了productNumner
,还是我应该使用join(我见过很少的帖子,但不能理解)并包括了{{1 }}(因为它也具有主键),只想了解正确的方法即可。
main_product_sub_category
库存数量未定义。
请提出任何建议。
Error:
- connection.query("UPDATE main_product_info SET stockQuantity=? WHERE main_product_info.producNumber=?",[stockQuantity - 1,checkQuantity],function (err,result) {}
// here i am looking to decrese stockQuantity by 1
-main_product_info
的代码使用show create table,
Snippet
解决方法
您可以在mysql中直接使用不带参数的
connection.query("UPDATE main_product_info SET stockQuantity= stockQuantity - 1 WHERE main_product_info.producNumber=?",[checkQuantity],function (err,result) {}
// here i am looking to decrese stockQuantity by 1