4
First I will present the database structure:
Order table:
id
cliente
data
status
Table Items:
id
produto
tamanho = Estoque.id
quantidade
pedido = Pedidos.id
Stock Table
id
tamanho
quantidade
chave = Produto.id
Product Table
id
codigo
nome
preco
It is a clothing store, so a products can have 1 or N sizes and each size can have 0 or N pieces in stock
I would like to create a Rigger, so that when updating the order status to 3(Paid), the stock table is updated, decreasing the quantity of products purchased in this order
would be something like
"update stock quantity=(quantity-items.quantity) Where items.id...
Then I don’t know if the beginning has any meaning when it comes to mysql and how to continue after that so that everything happens correctly...
Thank you in advance
Recurring problem , a Google search and you find lots of examples practically ready. https://www.google.com/search?q=mysql+triggers+controle+estoque&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-BR:official&client=firefox-a&channel=sb&gfe_Rd=cr&ei=7dWtU4_ZI6ek8wesoIDQBA
– Motta
see http://answall.com/questions/151684/controle-de-stocking-trigger-no-mysql-vs-l%C3%B3gica-na-aplica%C3%A7%C3%A3o-php/151691#151691
– Intruso