The MySql
has ;
as the end of each query
, in which case it is trying to execute two querys
instead of one, precisely because ;
is separating.
In order to avoid this, it is necessary to show MySql
what ;
is not ending query
and yes it is part of the context, for that there is DELIMITER
, in your case it would look like this :
DELIMITER $$
CREATE TRIGGER atualiza_produto AFTER INSERT ON item_venda FOR EACH ROW
BEGIN
UPDATE produto SET vendido = 's' WHERE id = NEW.id_produto;
END
$$
Everything between DELIMITER $$
and $$
should be performed together and not separating querys
to ;
.
See more here .