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

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//

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?