Trigger with column check

0

I need to make a trigger in mysql, but I need it to run only when there is an update in the auctions that change the status to 3 or 4.

It is of type AFTER UPDATE

BEGIN
IF (NEW.status IN ('3','4')) THEN

QUERY_AQUI

END IF;
END
    
asked by anonymous 05.04.2018 / 20:28

2 answers

0

The logic is correct. Anyway, here's an example code:

link

    
06.04.2018 / 19:07
0

The form your code is in was not created trigger , to create it you need to specify CREATE TRIGGER nome_da_trigger

CREATE TRIGGER minha_trigger
AFTER UPDATE
ON minha_tabela FOR EACH ROW

BEGIN
    IF (minha_tabela.status IN ('3','4')) 
    THEN

    QUERY_AQUI

    END IF;
END;
    
06.04.2018 / 19:14