javascript - using mysql how to insert rows in audit table? -
i new mysql, have 2 table employee , audit
employee table have 4 columns
- id
- name
- sal
- role
audit table have 7 columns
- id
- type
- old_value
- new_value
- date
- username
here , want insert 3 rows in audit table if add 1 row in employee table. maintain history
for eg: made entry in employee table
john | 20,000 | anaylst than audit table
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 unable insert rows in audit table.
use 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 answer details: mysql triggers insert table
Comments
Post a Comment