Automatic sum in mysql -
i have 3 fields in table num1
, num2
, num3
.
i need average of these 3 in field avgnum
.
user insert values of num1
, num2
, num3
using insertion query.
is possible make?
you can create trigger, this:
create trigger `new_table_before_insert` before insert on `new_table` each row set new.avgnum = (new.num1+new.num2+new.num3)/3
Comments
Post a Comment