2
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 ;
Ramon, could give more details of what types of information you will update?
– gmsantos
Maybe you need to Rigger in both tables, where the first Rigger sends an update that updates the second Rigger.... I don’t know... more details are better to direct you.
– gmsantos
Ok. Well 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.
– Ramon Chaves
The doubt is how I say update the Taba.field = free Where Tabb.field = off and Taba.id = Tabb.id
– Ramon Chaves
Prefer [Edit] your question instead of leaving the details only in the comment. It helps a lot for the next ones to read your question. Try to make a [tour] to better understand how to improve your questions ;)
– gmsantos