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

Thread Solved

Join Date: Sep 2009
Posts: 1
Reputation: josjorge is an unknown quantity at this point 
Solved Threads: 0
josjorge josjorge is offline Offline
Newbie Poster

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

 
0
  #1
Sep 27th, 2009
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??
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 79
Reputation: Kruptein is an unknown quantity at this point 
Solved Threads: 5
Kruptein's Avatar
Kruptein Kruptein is offline Offline
Junior Poster in Training

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

 
0
  #2
Sep 28th, 2009
in one query:
  1. 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..)
Last edited by Kruptein; Sep 28th, 2009 at 7:10 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training

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

 
-1
  #3
Oct 5th, 2009
or you can like be all cool and be like well find the column names and then do it with php $column1 - $ column2
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC