-1
I have a table on Mysql with the name usuários
with the following items: convite
,quantidade_de_convites
. I want when adding an invitation, update the amount how I do it?.
-1
I have a table on Mysql with the name usuários
with the following items: convite
,quantidade_de_convites
. I want when adding an invitation, update the amount how I do it?.
0
If you want to update the user table after inserting a record in the invitation table, you can use a TRIGGER. Here’s an example:
DELIMITER $$
CREATE TRIGGER update_convite AFTER INSERT ON convite
FOR EACH ROW BEGIN
UPDATE usuarios SET quantidade_de_convites = quantidade_de_convites + 1 WHERE USUARIO_ID = NEW.USUARIO_iD;
END $$
DELIMITER ;
In the case of this example, the user table would receive a field called user_id, it would be the key to update the user table
Here is a tutorial explaining how triggers work
Browser other questions tagged php mysql
You are not signed in. Login or sign up in order to post.
need to do something before creating the Trigger? here is giving table error
– Julio Cezhar