additions and Subtraction

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Love_Daddy
Forum Commoner
Posts: 61
Joined: Wed Jul 10, 2002 6:55 am
Location: South Africa
Contact:

additions and Subtraction

Post by Love_Daddy »

Hi All,

I need to do the following in PostgreSQL

1) Get a number from a user
2) Add or substract the number to an existing number in the database

For instance:

A user enters 10 to a form..

and in my database I have 15 of which I need to substract from the user number
how do I write the select?

I've tried:
Select value - $user_value as new_value from Table
So how do I update the table? - so that my new valuew will show?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

thoses seem pretty basic, have you tried the documentation at there site?
User avatar
Love_Daddy
Forum Commoner
Posts: 61
Joined: Wed Jul 10, 2002 6:55 am
Location: South Africa
Contact:

Post by Love_Daddy »

Okay! - I figured it out.
What I did was, After accepting a value from a user, I do my basic calculations using
PHP and then update my table.

Very easy!
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

good work! :wink:
Post Reply