I wish to make a Stock Control Rigger, but do not know how to do it

Asked

Viewed 224 times

1

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

1 answer

1


On your system when purchasing use the following SQL command:

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

Instead of 1 put 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 repeating structure.

I hope I’ve helped. :)

  • but like, how would I do that? I want q at the time we insert a product already decreasing automatically from stock, I would do it using a Trigger?

  • You can do it the way you think best, da to do it using Rigger, or when the person for example click on finish the purchase you run the mysql function.

  • how would you look using Trigger? I don’t know how to implement a Trigger

  • I’m not the best person to explain to you how to do this with Rigger, because I make sql requests and then give an update for example. I do the Insert first in the shopping table and after an update in the products table to decrease the stock. Got it?

  • thank you very much my friend, your logica helped me mt, solved my problem

Browser other questions tagged

You are not signed in. Login or sign up in order to post.