SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: update and math

  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    update and math

    I have a table, field A B C D and E.

    I want to add a new field F. So far Im good.

    I want to run a sql statement that will update all rows. I want F = ((A + B) / C) * D - E

    How would I make this update?

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is F always = ((A + B) / C) * D - E?
    Then you don't need the new field

    Update statement?
    update your_table set F = ((A + B) / C) * D - E !

    NB! If F is unsigned and (for example)
    A=1, B=2, C=3, D=4, E=5, then...
    ((1+2)/3)*4-5 = -1, but F will be set to 0


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •