DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Calculating arithmetic functions

  1. #1
    Join Date
    Aug 2005
    Posts
    3

    Calculating arithmetic functions

    Hi

    I need help to create a query that adds 4 values in my table when they are input.
    I then want to insert them into the table.
    This is the source code I'm using and I'm not getting anywhere. If you know whats wrong please let me know.

    Thanks Nick


    The code being used
    scode = Request("scode")
    ucode = Request("ucode")
    fridge = Request("fridge")
    outmech= Request("outmech")
    prizes= Request("prizes")
    pos= Request("pos")
    comments = Request("comments")

    SELECT SUM(`fridge`,`outmech`) AS `score`" &_
    " COUNT(*) AS score"


    strSQLUsers = "INSERT INTO `triindep` (`scode`,`ucode`,`fridge`,`outmech`,`prizes`,`pos`,`comments`,`score`) " &_
    " VALUES ('" & scode & "','" & ucode& "','" & fridge & "','" & outmech & "','" & prizes & "','" & pos & "','" & comments & "','" & score & "')"[/COLOR]

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Why not simply add the fridge and outmech values before doing the INSERT:

    scode = Request("scode")
    ucode = Request("ucode")
    fridge = Request("fridge")
    outmech= Request("outmech")
    score = fridge + outmech
    prizes= Request("prizes")
    pos= Request("pos")
    comments = Request("comments")

    strSQLUsers = "INSERT INTO triindep ('scode', 'ucode', 'fridge', 'outmech', 'prizes', 'pos', 'comments', 'score') " &_
    " VALUES ('" & scode & "', '" & ucode& "', '" & fridge & "', '" & outmech & "', '" & prizes & "', '" & pos & "', '" & comments & "', '" & score & "')"

    Also, you should not put quotes around the table name (triindep).
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2005
    Posts
    3

    Thanks

    Hi Phil

    Thanks it worked like a charm. Was completely missing the easy option!!
    Nick

Similar Threads

  1. Replies: 5
    Last Post: 08-15-2005, 12:52 AM
  2. virtual functions & name hiding
    By pseudo in forum C++
    Replies: 2
    Last Post: 04-04-2005, 04:16 PM
  3. Replies: 16
    Last Post: 05-26-2001, 04:09 PM
  4. Replies: 0
    Last Post: 05-18-2001, 08:23 PM
  5. RRAS Dll functions in VB
    By Duke Witchel in forum VB Classic
    Replies: 0
    Last Post: 04-20-2000, 11:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center