How to make a Trigger Delete with validations

Asked

Viewed 106 times

2

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

That’s 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

tabela locações

inserir a descrição da imagem aqui

Use phpmyadmin, and I’m a beginner in mysql

  • Is it really necessary to use Trigger? There is an application consuming this database?

  • Yes, it’s my course work

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.