这是触发器:
create trigger tg1
after insert on table1
for each row
begin
update table2 set amount=if(isnull(amount),0,amount)+1 where t2_id=new.t1_id;
end;
如何优化:amount=if(isnull(amount),0,amount)+1
感谢
答案 0 :(得分:2)
相当清洁:
amount=IFNULL(amount,0)+1