automatically fill in mysql intermediate tables

0

I am trying to fill an intermediate table automatically from another one, the example is as follows.

where when filling the table SPECIFICALLY the salary field (# 13) it should be filled in the following intermediate table as a record only.

probe the relationship from table 1 to table 2 with cascade type but only saved in table 1.

    
asked by matteo 23.01.2017 в 20:48
source

1 answer

1

To be able to do what you want to do, it is necessary to do Trigger in the following way:

CREATE TRIGGER insert_on_tabla2  
    --Indicas de donde proviene la acción a ejecutar en tu caso después de insertar en la tabla1.
    BEFORE INSERT ON tabla1
    FOR EACH ROW 
    BEGIN 
    --Se realiza la acción que se desea hacer.
    INSERT INTO tabla2 (salario) VALUES (NEW.salario); 
END
    
answered by 23.01.2017 в 21:17