木子大大
2019-05-12 08:43
采纳率: 100%
浏览 813

MySQL创建触发器时报错Error Code: 1064

问题描述:
Error Code: 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 9

代码如下:

图片说明

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 木子大大 2019-05-27 18:06
    已采纳

    已解决
    需要加delimiter

    delimiter //
    DROP TRIGGER IF EXISTS add_ticket;
    CREATE TRIGGER add_ticket
    before INSERT ON ticket
    FOR EACH ROW
    begin
    if new.ccol not in(select distinct ccol from Seat
    where Cin_id=new.Cin_id and Hall_id =new.Hall_id and rrow=new.rrow )
    then
    insert into seat(Cin_id,Hall_id,rrow,ccol) values(new.Cin_id,new.Hall_id,new.rrow,new.ccol);
    end if;
    if new.price>100
    then
    SIGNAL SQLSTATE 'HY000' SET MESSAGE_TEXT = '价格过高' ;
    end if;
    end//

    已采纳该答案
    打赏 评论
  • threenewbee 2019-05-12 10:20

    没写完整,下面加上一个 END IF

    打赏 评论

相关推荐 更多相似问题