当我使用下面提供的phpmyadmin在mysql中执行我的创建触发器查询时,我的mySql查询出错了。
错误:
错误讯息:
#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查询:
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
我不知道我的查询有什么问题。任何人都可以帮我找到解决方案。
答案 0 :(得分:1)
我注意到的IF NEW.ismarried == 'Yes' THEN
很少有IF NEW.ismarried = 'Yes' THEN
BEGIN
和END IF
应以分号;
结尾,尽管BEGIN
结束END;
}}
但是因为我试图使用phpmyadmin执行此查询,所以我必须从phpmyadmin的底部文本框中删除Delimiter。 但请注意,这只是phpmyadmin分析警告而不是mysql服务器响应。