当表A发生插入或更新isprivate字段时,将表A的这条数据更新到表B的isprivate字段上
1条回答 默认 最新
@152.com 2021-10-20 16:23关注zyd-----中间表
othermain ----------需要更新的正式表
若zyd的ISPRIVATE=1,修改为2,正式表也要修改为2,若zyd的ISPRIVATE=2,修改为1,正式表也要修改为1
下面这个是我写的,这个写法是错误的,各位老师帮忙看下吗
例如:
CREATE trigger fk
AFTER update
on zyd
for each row
begin
if EXISTS(select *from othermain oth WHERE oth.ISPRIVATE=new.ISPRIVATE LIMIT 1)
THEN
if zyd.isprivate=1
then
update OtherMain set isprivate=2 where billno=''{?bill_id}''
else if
zyd.isprivate=2 then
update OtherMain set isprivate=1 where billno=''{?bill_id}''
end if
END解决 无用评论 打赏 举报