How to subtract each item from a table ( sql server 2008)
The actual tables..
The top left is the assembly table
The top right is the items_table
the bottom left is the inventory table
I wanted to update the inventory based on the orders..开发者_如何学编程
each product has multiple inventory items and I need to multiple each quantity in assembly_table by the quantity in items_table
You could join the tables together to multiply quantities with the same product_tuid
:
select a.product_tuid
, a.quantity * i.quantity as QuantityProduct
from assembly_table a
inner join
items_table i
on i.product_tuid= a.product_tuid
精彩评论