I am new to mysql, I have two table employee and audit
employee Table have 4 columns
audit Table have 7 columns
Here , I want to insert 3 rows in audit table if someone add one row in employee table. To maintain the history
for eg: I made an entry in employee table
John | 20,000 | anaylst
Than my audit table will be
Type | old_value |new_value | date | username
name| |John | 01/04/2015 | dummy1
sal| |20,000 | 01/04/2015 | dummy1
role | |anaylst | 01/04/2015 | dummy1
I am unable to insert rows in audit table.
Use a trigger.
https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html https://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
See this answer for details: MySQL Triggers insert into another table
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.