954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Substract two field values to insert the result into a third value

Hi,

I have this question, having two numeric values field1 and field2, i need field3 by default to be the difference between field1 and field , any idea??

josjorge
Newbie Poster
1 post since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

in one query:

UPDATE table SET field3 = field1-field2


I think this should work.

(everytime you update/change a value of field1/field2 you will have to do this query, mysql can't do this automatic..)

Kruptein
Posting Whiz in Training
258 posts since Sep 2009
Reputation Points: 25
Solved Threads: 11
 

or you can like be all cool and be like well find the column names and then do it with php $column1 - $ column2

SKANK!!!!!
Posting Pro in Training
429 posts since Apr 2009
Reputation Points: 15
Solved Threads: 7
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You