I have two tables one apartment to another contract. When the status of the contract is changed to off
. The status of the apartment is free. I have a foreign key in the contract table to relate to apartment.
I would like to know how to create a trigger to update an apartment table field after updating a contract table field.
DELIMITER //
CREATE TRIGGER upd_tab_b BEFORE UPDATE ON tab_b FOR EACH ROW BEGIN
UPDATE tab_a
SET campo_a = livre
WHERE 1 = 1;
-- a dúvida é como dizer atualize --quando o campo da tabela B for --igual a off
END;
// DELIMITER ;