1
create table Test1
(
WRO varchar(10),
Test_No varchar(10),
TestDate datetime
);

insert into Test1(WRO,TestDate) values('T0001',now());
create table Test2
(
WRO varchar(10),
Test_No varchar(10),
Test2Date datetime,
TestAmount varchar(10)
);

我必须Test1 Test_No在插入Test2表后更新,Test_No两者都有共同的字段WRO

4

2 回答 2

0

Try the following,

delimiter |    

CREATE TRIGGER after_insert AFTER INSERT ON Test_2
    FOR EACH ROW BEGIN
    UPDATE Test_1 SET Test_1.Test_No = Test_2.Test_No WHERE <YOUR CONDITION>
END;

|

make sure you edit WHERE to match your condition

you may also want to consult here to get better understanding on triggers

于 2012-10-08T10:25:28.680 回答
0
delimiter |
CREATE
    TRIGGER trigger1 
     AFTER INSERT ON test2
    FOR EACH ROW BEGIN
     UPDATE test1 SET test1.Test_No=new.Test_no where test1.WRO=new.WRO;    
    END;
    |
于 2012-10-08T10:41:56.697 回答