I have two tables Employee and Employee Log, I created a trigger after insert, I have no problem with my after insert trigger using entities or values from employee, to insert directly to Log table, but how would I insert value from another table? like Admin_ID. I want a log table with transaction, datetime and who created.
Thank you.
CREATE TRIGGER emp_log_af AFTER INSERT ON emp
FOR EACH ROW
BEGIN
INSERT INTO emp_log (action,id,ts, ad_id)
VALUES('create',NEW.id,NOW());
END;
CURRENT_USER
? OrSELECT SUBSTRING_INDEX(USER(),'@',1) from dual
Pulled from here – TaW