begin declare num int; set num=(select count(*) from 表名 where BusinessId=new.Id and businessType=2 and Type=10); if num=0 then insert 表名(Id,Type,BusinessId,businessType,Status,Count,IsDeleted) values(uuid_short(),10,new.Id,2,2,1,1); else update 表名 set Count=0 where BusinessId=new.Id and businessType=2 and Type=10; end if; end
参考:https://blog.csdn.net/qq_15058425/article/details/72673788
原文:https://www.cnblogs.com/LJing21/p/11935598.html