I have two tables, one with the sessions and another with the activities. Within the activities table I have two fields, available and salable and within session I have vacancies.
I would like to get the id of the session to be able to do the update in the salable field, when zerosse the vacancies that the activity.vendible field did update to 0.
DELIMITER $$
CREATE TRIGGER atualizarStatus
AFTER UPDATE ON sessao
FOR EACH ROW
BEGIN
IF (sessao.vagas = 0) THEN
UPDATE atividade SET vendivel = 0 WHERE id = $id;
END IF;
END;