MySQL Trigger on after insert

后端 未结 4 528
别那么骄傲
别那么骄傲 2020-12-14 17:25

I am new to MySQL. I have two tables total_loaner and available_loaner. I am trying to create a trigger for every new row added in total_loaner, I would to add that new row

4条回答
  •  一整个雨季
    2020-12-14 17:49

    You probably need to set your delimiter:

    DELIMITER $$
    
    CREATE TRIGGER new_loaner_added 
    AFTER INSERT ON `total_loaner` for each row
    begin
    INSERT INTO available_loaner (Kind, Type, Sno, Status)
    Values (new.Kind, new.Type, new.Sno, 'Available');
    END$$
    
    DELIMITER ;
    

    Right now, it's confusing the semi-colon at the end of the INSERT statement with the end of the CREATE TRIGGER statement.

提交回复
热议问题