如果触发条件

时间:2010-01-11 07:30:48

标签: mysql triggers

我有一个拖车名称t1,t2。基于t1中的值插入我想插入t2。 我使用以下触发器。

create trigger testt after insert on t1
BEGIN
for each row
if NEW.uid='Mill' then insert into t2 (uid2) values (NEW.uid)
end if
 if NEW.uid='Farm' then insert into t2 (uid2) values (NEW.r)
end if
END

请帮我解决此问题。提前致谢

2 个答案:

答案 0 :(得分:1)

看起来你只是有些关键字无序:

CREATE TRIGGER ...
FOR EACH ROW 
BEGIN
    ...
END

答案 1 :(得分:0)

create trigger testt after insert on t1
BEGIN
for each row BEGIN
if NEW.uid='Mill' then insert into t2 (uid2) values (NEW.uid)
end if
 if NEW.uid='Farm' then insert into t2 (uid2) values (NEW.r)
end if
END
相关问题