Good colleagues, I have a problem that I still can not solve. I want to create a trigger that whenever the column of quantity of product undergoes a update it triggers an action for another table, to allow the user to know that a certain product has increased or decreased. Is it possible in mysql? If so, what would be the logic?
Table that has been updated in the quantity field
'producto', 'CREATE TABLE 'producto' (\n
idProducto' int(11) NOT NULL AUTO_INCREMENT,\n
'artigo' int(11) NOT NULL,\n 'data' datetime NOT NULL,\n
'tipoProducto' varchar(50) NOT NULL,\n
'descricao' mediumtext NOT NULL,\n
'quantidade' int(11) NOT NULL,\n
'validade' date DEFAULT NULL,\n
PRIMARY KEY ('idProducto')\n) ENGINE=InnoDB DEFAULT CHARSET=utf8'
Table where the action will be triggered
''entrada_producto', 'CREATE TABLE 'entrada_producto' (\n
'idEntrada' int(11) NOT NULL AUTO_INCREMENT,\n
'idProducto' int(11) DEFAULT NULL,\n
'dataEntrada' datetime DEFAULT NULL,\n
'quantidade_entrada' int(11) DEFAULT NULL,\n
'descricao' mediumtext,\n
PRIMARY KEY ('idEntrada'),\n KEY 'idProducto' ('idProducto'),\n CONSTRAINT 'entrada_producto_ibfk_1' FOREIGN KEY ('idProducto') REFERENCES 'producto' ('idproducto')\n) ENGINE=InnoDB DEFAULT CHARSET=utf8''