Search code examples
mysqlmysql-error-1064

Mysql Trigger creation query - Syntax error


I am getting an error in my mySql query when i execute my create trigger query in mysql using phpmyadmin which is provided below.

Error:

enter image description here

Error Message :

#1064 - 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 '' at line 5

MySql Query:

CREATE TRIGGER Trigger_INSERT_club_app_member_contact_info After INSERT ON club_app_member_contact_info
FOR EACH ROW
BEGIN
  INSERT INTO club_app_events_list(type_id,event_title,event_description,event_date,event_time,event_venue)
              values(1,CONCAT('Happy Birthday ',NEW.title,NEW.name),NEW.mobile_no,NEW.dob,'8.30AM','');
  IF NEW.ismarried == 'Yes' THEN
          INSERT INTO club_app_events_list(type_id,event_title,event_description,event_date,event_time,event_venue)
                      values(1,CONCAT('Happy Birthday ',NEW.title_for_spouse,NEW.nameOf_spouse,'Spouse of (',NEW.title,NEW.name,')'),NEW.spouse_mobileNo,NEW.spouse_dob,'8.30AM','');
          INSERT INTO club_app_events_list(type_id,event_title,event_description,event_date,event_time,event_venue)
                      values(2,CONCAT('Happy Wedding Anniversary to ',NEW.title,NEW.name ,' & ',NEW.title_for_spouse,NEW.nameOf_spouse),NEW.mobile_no,NEW.weeding_date,'8.30AM','');      
  END IF
END

I don't know what's wrong with my query.Can anyone help me to find a solution.


Solution

  • Few thing i noticed IF NEW.ismarried == 'Yes' THEN it should IF NEW.ismarried = 'Yes' THEN BEGIN and END IF should end with semicolon ; although BEGIN end enclose END;

    But since i am trying to execute this query using phpmyadmin I have to remove Delimiter from the bottom text box of phpmyadmin. But note that this is only phpmyadmin analysis warnings not a mysql server response.