我有3个表:badge_master,match_result_updation和team_badges。
badge_master是主表,我手动将数据插入到Excel中。在match_result_updation
我有一些列if sum(goal_column1) - sum(goal_column2) = 10
,然后值column1将获得徽章,它将插入team_badges表中。我通过触发器处理它但在一段时间后无法继续。
我试过的触发器:
CREATE TRIGGER `afterinsert_teamgoals` AFTER INSERT ON `match_result_updation` FOR EACH ROW
BEGIN
DECLARE goalCount1 INT(10);
DECLARE goalCount2 INT(10);
DECLARE badgeId BIGINT(20);
DECLARE teamId bigint(20) default 0 ;
SELECT team1_goal INTO goalCount1 FROM match_result_updation WHERE team1_id = NEW.team1_id ;
SELECT team2_goal INTO goalCount2 FROM match_result_updation WHERE team2_id = NEW.team2_id ;
IF (goalCount1 - goalCount2 >= 10)
Then
Insert into team_badges(team_id,badge_id,match_id,timestamp)
SELECT teamId , badgeId , match_id FROM match_result_updation limit 1;
END IF;
请协助。