Trigger to update another table

0

I have 4 table in my Mysql database. - > companies - > contacts (business addresses) - > bank_data (company bank details) - > partners (company partners)

All tables relate to the companies table. In the companies table I have an updated_at field, which I would like when updating any of the other 3 tables, this field was updated. I thought of a TRIGGER, but I do not know how to do it.

    
asked by anonymous 20.12.2016 / 14:55

1 answer

1

So:

CREATE TRIGGER socioup AFTER UPDATE
ON socios
FOR EACH ROW
BEGIN  
   UPDATE empresas SET updated_at = NOW() WHERE empresa_id = new.empresa_id;
END
    
20.12.2016 / 15:06