如何优化这个 sql
how to optimize this sql
这是一个触发器:
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
谢谢
干净多了:
amount=IFNULL(amount,0)+1
这是一个触发器:
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
谢谢
干净多了:
amount=IFNULL(amount,0)+1