I'm having difficulty with the if () syntax in phpmyadmin. I have to create a TRIGGER to insert information into a log when the name of an animal in the animals table is changed. But it's giving syntax error in if (). When I take the if it works. Can anyone help?
Follow the code below:
DELIMITER $$
CREATE TRIGGER log_update
AFTER UPDATE ON animais
FOR EACH ROW
IF ( OLD.nome_animal <> NEW.nome_animal) THEN
INSERT INTO log_animais(codigo, momento, ocorrencia) VALUES ( OLD.cod_animal, now(), OLD.nome_animal )
END
$$
DELIMITER ;
When I put the BEGIN, END and / or END IF it also gives the error.