#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    2
    Rep Power
    0
    Is there a way in which I can add (or subtract) a couple of columns and spit the result into a different column? For example:

    Subtract the value of 'ship decimal(4,2)' from the value of 'gross decimal(4,2)' and automagically put the result into 'net decimal(4,2)'

    Thanks for your help!
    paul
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    yep...try this:

    UPDATE your_table SET net = gross - ship;

    That will do it for all of the rows, you can add a WHERE clause on the end to specify what rows if you need to.

    ---John Holmes..
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    2
    Rep Power
    0
    Hey, Thanks. I just figured out how to tally a running total during the php output, but I like the idea of having a total in the DB better.



    [This message has been edited by felsheim (edited November 09, 2000).]

Similar Threads

  1. Replies: 1
    Last Post: February 6th, 2004, 05:53 AM
  2. Inserting from form to multiple tables
    By barth in forum MySQL Help
    Replies: 0
    Last Post: January 25th, 2004, 09:27 AM
  3. put variable in text field
    By alexmasters in forum PHP Development
    Replies: 3
    Last Post: January 14th, 2004, 07:32 PM
  4. return value from 3 fields into 1 field
    By denali in forum MS SQL Development
    Replies: 1
    Last Post: December 19th, 2003, 07:44 AM
  5. Validating a field with multiple criteria...
    By brotherloco in forum Java Help
    Replies: 0
    Last Post: October 29th, 2003, 07:40 AM

IMN logo majestic logo threadwatch logo seochat tools logo