Create a trigger. The trigger creation syntax is as follows:
Create trigger trigger_name trigger_time trigger_event
ON tbl_name for each row trigger_stmt
Trigger_name indicates the trigger name, which you can specify;
Trigger_time indicates the trigger time, which must be replaced by before and after;
Trigger_event identifies the trigger event and replaces it with insert, update, and delete;
Tbl_name identifies the table name on which the trigger is created;
Trigger_stmt is the trigger program body. The trigger program can use begin and end as the start and end, with multiple statements in the middle;
The existing sys_log_login table and two-dimensional table need to query whether the sys_login_record table has the same records as the fd_operator_id in the sys_log_login table when inserting a record in the sys_log_login table;
Create Trigger loginRecord
After insert
On sys_log_login for each ROW
BEGIN
If not exists (select fd_operator_id from sys_log_login_record where fd_operator_id = NEW. fd_operator_id) then
Insert into sys_log_login_record values (NEW. fd_id, NEW. fd_operator_id, NEW. fd_create_time );
End if;
End;
Delimiter;