Update table B on Insert into table A

from the Artful MySQL Tips List



drop table if exists a,b;
create table a(id int);
insert into a values(1);
create table b(id int,counter int);
insert into b values(1,0);

CREATE TRIGGER a_update_b AFTER INSERT ON a 
  FOR EACH ROW 
    UPDATE b SET counter=counter+1 WHERE id=new.id;




Return to the Artful MySQL Tips page