27,579
社区成员
发帖
与我相关
我的任务
分享
create table a(aid int,aname varchar(20),ams varchar(100),flag int)--
insert into a select 1,'小李','空',0
insert into a select 2,'小王','空',0
create table b(bid int,bname varchar(20),bms varchar(100),flag int)
create trigger tri_a
on a
instead of update
as
begin
insert into b select * from inserted
where not exists(select 1 from b where bid=inserted.aid)
update a set flag=case when inserted.flag=2 then 2 else 1 end from a ,
inserted where a.aid=inserted.aid
end
create trigger tri_b
on b
for update
as
begin
update a set a.flag=inserted.flag from a,inserted where a.aid=inserted.bid
end
update a set ams='要求会员' where aid=1
update b set flag=2 where bid=1
update a set ams='要求会员' where aid=2
update b set flag=1 where bid=2
select * from a
select * from b
加个字段表示一下是否审核啊,ifshenhe 审核了改为真 ,默认是假
select * from tb where ifshenhe='true'