本文介绍了sql库存 - 想知道商店剩下多少件商品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我的主要问题是我想知道商店里剩下多少件物品,如{table1.column - table2.column} 和我的问题不明确我会尝试说出我想要完成的事情 i创建了包含许多表格的视图,如果我设置laptop_quantity = 25 第一批客户需要5我想要数量自动等于 - 分配 ID |客户:项目| location | quantity_store |分配| 1 [johns] [Lapto] [ITdep] [20] [5] 2 [james] [Lapto] [ITdep] [16] [4] 3 [cilena] [电脑] ] [Accessdep] [16] [0] 所以这可以通过触发器或什么来完成? 任何答案都会如此赞赏 抱歉如果我的问题不清楚解决方案 和建议答案是 CREATE PROC dbo.ProcessOrder @ Item int , @ Quantity int AS BEGIN - 此处更新订单表 INSERT INTO dbo.Orders(ItemID,Quantity) VALUES ( @ ItemID , @ Quantity ) - 此处更新库存 更新 dbo.Inventory SET CurrentQuantity = CurrentQuantity - 数量 WHERE ItemID = @ ItemID 结束 但我仍然无法理解这是如何工作的?我知道触发器可以向表插入值但存储生产者如何? 任何教程或想法将再次受到赞赏 hi everyone ,,my main question is i want ti know how many items left in store like {table1.column - table2.column}and if my question is not clear i will try say what i want accomplishi have created view that consist of many table and if i set laptop_quantity=25 the first customers took 5 i want quantity automatically be equaled - assign ID |Customers: items | location |quantity_store| assign|1 [ johns ][ Lapto ] [ ITdep][ 20 ] [ 5 ] 2 [ james ][ Lapto ] [ ITdep ][ 16 ] [ 4 ] 3 [cilena ][computer] [Accessdep][ 16 ] [ 0 ]so is this can be done by trigger or what?any answer will be so appreciatedand sorry if my question is not clear 解决方案 and the suggest answer is CREATE PROC dbo.ProcessOrder @Item int, @Quantity intASBEGIN --Update order table here INSERT INTO dbo.Orders(ItemID,Quantity) VALUES (@ItemID, @Quantity) --Update Inventory here UPDATE dbo.Inventory SET CurrentQuantity = CurrentQuantity - Quantity WHERE ItemID = @ItemIDENDbut i still cannot understand how does this works i? i know trigger can insert value to table but store producer how ? any tutorial or idea will be so appreciated thanks again 这篇关于sql库存 - 想知道商店剩下多少件商品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 09:53