How to calculate subtraction of two fields and keep that ans in third fields in mysql in same table? -
i have 3 fileds namely num1 num2 , num3/ans wanted subtract num1 , num2 filed , ans should there in num3/ans field ex num1 value 400 , num value 100 value in ans/num3 field should there automatically
do need this?
update tbl set num3 = num1 - num2
or if want calculated field, impossible directly,but can utilize trigger
create trigger mytrigger before insert on tbl each row set new.num3 = new.num1 - new.num2;
mysql
No comments:
Post a Comment