How to do a Delete trigger with validations

2

I have the following problem, I want it after I delete a lease from the leases table I go in the table in the movies and make the situation column stay as available, but in case if I have the movie code in the leases table in another record, I still leave the movie table situation column as leased, how would I do it?

This is what I've done.

TRIGGER 'tguDelete' AFTER DELETE ON 'locacoes' FOR EACH ROW UPDATE filmes SET situacao = 'Disponivel' WHERE id_locacao = OLD.id_locacao

These are my tables

I use phpmyadmin, and am a beginner in mysql

    
asked by anonymous 08.10.2016 / 22:37

0 answers