Log in

View Full Version : problem in creating a trigger



heavensgate15
06-30-2010, 12:14 AM
Hi,

I have this code in creating a trigger:




create trigger trigger1_trigger on trigger1 for insert
BEGIN

insert into trigger2(t2name) values("myname");

END



I don't know the rules in creating a trigger, and this code won't work. What I want to achieve was that, if I inserted a new row to trigger1 table, the new row (the name column only) will be inserted automatically to trigger2 table. How do I do that using trigger?

LIST OF TABLES AND ITS ATTRIBUTES:

table : trigger1
attributes:
t1id int not null auto_increment primary key
t1name varchar(40)
t1age int

table : trigger2
attributes:
t2id int not null auto_increment primary key
t2name varchar(40)

djr33
06-30-2010, 08:15 AM
1. Please only post once. Your other thread in PHP has been deleted. (If you are unsure about where to post when a question overlaps between two areas, either one will be fine, but posting twice will just create confusion.)

2. This should be easy enough to answer with google-- search "mysql trigger" (+syntax, if needed). I've never used it, but it looks like you're just trying to find the standard syntax for this, right?