I want to trigger a Stock control, but I do not know how to do it

1

I want to create a table called 'product' that has its id and the quantity in the inventory and another table called 'purchase, the purchase table will have the primary key of the product and the id of the purchase, so I wanted to decrease the quantity in the 'product' table inventory every time a purchase is made, how would you do that?

    
asked by anonymous 16.06.2018 / 15:32

1 answer

1

On your system, when purchasing, use the following SQL command:

UPDATE 'produtos' SET 'estoque' = 'estoque' - 1 WHERE 'idProduto'

Instead of 1 place the variable that will define the amount of products purchased by the person.

If you need to do this in more than one product type, use a repeat structure.

I hope I have helped. :)

    
16.06.2018 / 16:46