Connecting Tech Pros Worldwide Forums | Help | Site Map

Subtract from current value

doomsday123@gmail.com
Guest
 
Posts: n/a
#1: Jul 11 '07
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.


teddysnips@hotmail.com
Guest
 
Posts: n/a
#2: Jul 11 '07

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

doomsday123@gmail.com
Guest
 
Posts: n/a
#3: Jul 11 '07

re: Subtract from current value


Exactly what I was looking for. Thanks!

Closed Thread