The following articles mainly describe the actual operation steps of MySQL trigger insert and the actual application code. This article mainly describes them in three examples, the following describes the specific content of the article. I hope you will find some gains.
MySQL trigger insert Example 1
- view sourceprint?01 delimiter //
- create trigger InsertUser
- before insert on user
- for each row
- Begin
- insert into user_group(uid,gid) values(new.uid,'group4444444444');
- end;//
- delimiter ;
MySQL trigger insert Example 2
- delimiter //
- create trigger InsertUser
- before insert on user
- for each row
- Begin
- IF new.Type=2 then
- insert into user_group(uid,gid) values(new.uid,'group4444444444');
- else
- insert into user_group(uid,gid) values(new.uid,'group55555555555')
- END IF;
- end;//
- delimiter ;
MySQL trigger insert Example 3:
- delimiter //
- create trigger InsertUser
- before insert on user
- for each row
- Begin
- IF new.type=1 then
- insert into user_group(uid,gid) values(new.uid,'578d3369633b47bd9c1fe8bf905cbfb1');
- END IF;
- IF new.type=2 then
- insert into user_group(uid,gid) values(new.uid,'387bcd57fc5a4c3c9de83ee210fef661');
- END IF;
- end;//
- delimiter ;
The above content is an introduction to the MySQL trigger insert. I hope you will get some benefits.