mysql - SQL After insert trigger insert multiple rows into another table -


so have following table:

table: competence columns: id  int(11) ai pk name    varchar(400) organization_id int(11) competence_type_id  int(11) competence_category_id  int(11) 

and following user table:

    table: user columns: id  int(11) ai pk username    varchar(100) password    varchar(100) is_active   int(11) user_type_id    int(11) token   varchar(445) organization_id int(11) title_id    int(11) image_path  varchar(100) division_id int(11) 

and following connection between these 2 tables:

table: user_has_competence columns: user_id int(11) pk competence_id   int(11) pk competence_level_id int(11) progression varchar(45) id  int(11) ai pk 

now im trying create trigger on competence table following:

after row has been inserted competence table find users same organization_id , each of these users insert user_has_competence user_id , competence_id.

however havnt worked triggers , hoping 1 of guys push me in right direction.

in mysql done as

delimiter // create trigger competence_ins after insert on competence each row  begin  insert user_has_competence (user_id,competence_id)  select u.id,c.id competence c  join user u on u.organization_id = c.organization_id , c.organization_id = new.organization_id; end;//  delimiter; 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -