[英]how to create trigger in mysql for insert data into table
Leave_applied_table:
leave_applied_id employee_id status start_date end_date_session hours
1 345 1 2016-6-25 2016-8-25 16
Leave_actula_table:
leave_applied_id leave_type_id hours created_at
345 2 16 2016-7-25
345 2 16 2016-7-25
345 2 16 2016-7-25
Leave_approval_table:
leave_approval_id leave_applied_id manger_id status
56 345 125 1
this is my three table i have to create triggger like when i insert in to Leave_applied then in leave_actual table three row should insert and in leave_approval_table in entry should come as given data in table please suggest me how to write query for this how to create trigger i am new in one this please suggest me for give issue . 这是我的三个表,我必须创建触发器,例如当我插入Leave_applied时,然后在leave_actual表中插入三行,并在条目中的leave_approval_table中插入表中给定的数据,请建议我如何编写查询以创建触发器我是新来的,请给我建议。
Try it like this: 像这样尝试:
DELIMITER $$
CREATE TRIGGER insert_trigger
BEFORE INSERT ON Leave_applied_table FOR EACH ROW
begin
insert into Leave_actula_table (Leave_actula_table.leave_applied_id,and so ON....) values(new.employee_id,new.leave_type_id) ;
insert into Leave_approval_table (Leave_approval_table.leave_applied_id, and so on....) values (new.employee_id and so on;
END;
$$
DELIMITER ;
Hope it helps you as a guide.. 希望它对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.