javascript - using mysql how to insert rows in audit table? -


i new mysql, have 2 table employee , audit

  1. employee table have 4 columns

    1. id
    2. name
    3. sal
    4. role
  2. audit table have 7 columns

    1. id
    2. type
    3. old_value
    4. new_value
    5. date
    6. 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

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -