sum of a column with a mysql trigger

2

I need your help since I'm not good at triggering (TRIGGER) in creating a trigger what happens that I have two tables one that is "player" and the other "team" as they are in the image

In the player table I have a stored process that makes a division in the "bouncing columns until I miss" and what I want the "trigger" to do is "add" what they are entering in the "player" table "of the" columns of bounces until missing "and that result shows it in the" team "table but also lets me enter the data" player_name "up to" weight "of that same table I hope you can help me

create trigger  llenar after insert on jugador 
for each row 
begin 
insert into equipo(IDE,nombre_equipo,categoría,DT,capitán,Total_Victorias,Total_Derrotas,(select sum(Rebotes) from jugador),(select sum(Tiro_Libre) from jugador),(select sum(Bloqueos) from jugador),(select sum(Faltas) from jugador));
    
asked by Gustavo 16.05.2016 в 04:14
source

1 answer

1

Why would you insert several times in the team table?

Ideally, insert the team players and only update their statistics according to each game.

Example Player 1 total wins 1-team table

When inserting a victory in the player table, the trigger summarizes the victory to the existing ones. Or you could generate the information with a JOIN.

    
answered by 20.05.2016 в 15:48