zjien
zjien

Reputation: 1

how to optimize this sql

This is a trigger:

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;

how to optimize : amount=if(isnull(amount),0,amount)+1

thanks

Upvotes: 0

Views: 50

Answers (1)

trex005
trex005

Reputation: 5115

Quite a bit cleaner :

amount=IFNULL(amount,0)+1

Upvotes: 2

Related Questions