Connecting Tech Pros Worldwide Help | Site Map

Subtract from current value

  #1  
Old July 11th, 2007, 05:25 AM
doomsday123@gmail.com
Guest
 
Posts: n/a
I want to create a query that will subtract a given number from a
value in the database and store it in the same spot the value was. For
example, a customer has a balance of 23.22 which is stored in a
balance column in the database and the user makes a payment of 10.00.
I want a query that will take the 10.00 and subtract it from the
23.22, and store the remainder back in the balance column which
previously stored the 23.22. Is it possible to do in one update
statement? Thanks.

  #2  
Old July 11th, 2007, 01:05 PM
teddysnips@hotmail.com
Guest
 
Posts: n/a

re: Subtract from current value


On 11 Jul, 05:15, "doomsday...@gmail.com" <doomsday...@gmail.com>
wrote:
Quote:
I want to create a query that will subtract a given number from a
value in the database and store it in the same spot the value was. For
example, a customer has a balance of 23.22 which is stored in a
balance column in the database and the user makes a payment of 10.00.
I want a query that will take the 10.00 and subtract it from the
23.22, and store the remainder back in the balance column which
previously stored the 23.22. Is it possible to do in one update
statement? Thanks.
Update MyTable SET Balance = (Balance - 10.00) Where CustomerID =
WhateverDude*;

* Insert your CustomerID or other identifying information here.

Edward

  #3  
Old July 11th, 2007, 02:15 PM
doomsday123@gmail.com
Guest
 
Posts: n/a

re: Subtract from current value


Exactly what I was looking for. Thanks!

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query to calculate liquid used from a tank PeterW answers 3 August 16th, 2006 08:15 PM
Subtract Hours from a Date Lee answers 4 November 16th, 2005 07:44 PM
Date calculator, add or subtract days to or from a given date dlx_son@yahoo.com answers 8 July 23rd, 2005 10:00 PM
mySQL add/subtract quantities? Westcoast Sheri answers 4 July 17th, 2005 09:20 AM