Click here to Skip to main content
15,886,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
DROP TRIGGER IF EXISTS `insert_points` ; CREATE TRIGGER `insert_points` BEFORE INSERT ON `p_players` FOR EACH ROW BEGIN SET NEW.total_points = NEW.gold_num + NEW.total_people_count + NEW.week_thief_points +NEW.week_dev_points +NEW.week_defense_points+NEW.week_attack_points+NEW.defense_points+NEW.attack_points+NEW.hero_points+NEW.villages_count; END;





when i try to create that trigger it gives me that error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TRIGGER `insert_points` BEFORE INSERT ON `p_players` FOR EACH ROW BEGIN ' at line 2



i use mysql
Posted
Comments
[no name] 19-Jul-14 11:13am    
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
nilesh sawardekar 20-Jul-14 2:32am    
your mysql version?
TheSniper105 20-Jul-14 6:21am    
4.0.4

1 solution

I am seeing syntax problems in your Trigger. The correct way should be like

SQL
DROP TRIGGER IF EXISTS insert_points;


CREATE TRIGGER insert_points
BEFORE INSERT
  ON p_players
  FOR EACH ROW 
BEGIN 

   SET NEW.total_points = NEW.gold_num + NEW.total_people_count + NEW.week_thief_points +NEW.week_dev_points+NEW.week_defense_points+NEW.week_attack_points+NEW.defense_points+NEW.attack_points+NEW.hero_points+NEW.villages_count;

END;
 
Share this answer
 
Comments
TheSniper105 20-Jul-14 6:19am    
what is the error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900