Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 11th, 2007, 05:25 AM
doomsday123@gmail.com
Guest
 
Posts: n/a
Default Subtract from current value

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
Default 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
Default Re: Subtract from current value

Exactly what I was looking for. Thanks!

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles