How to subtract fields and insert the value in other field automatically? id  val1   val2    total

1    10     4       10-4(automatically get the value)
.
.
.
.


I am using php and mysql. I have a total column I need to make calculation automatically in a field, how it can be done?
If this requirement is very important to you, take a look here - calculated fields in MariaDB - never any need to perform calculations - it's all taken care of for you! Although, as has been pointed out, you can always perform the calculations on the fly.