adding values from a database

Discussion in 'MySQL' started by Greenmethod, Oct 4, 2007.

  1. #1
    What would be the best way to add values from a database? I want to add 'price_to_cust' WHILE 'cust_out'=xxxx AND 'order_no'=xxxx.

    Would it be better to do this with php or is there an easy way to do it with mysql?
     
    Greenmethod, Oct 4, 2007 IP
  2. upl8t

    upl8t Peon

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use a group by with a sum.

    SELECT cust_out, order_no, SUM(price_to_cust) AS price_summed
    GROUP BY cust_out, order_no
    WHERE cust_out = XXX and order_no = YYY
     
    upl8t, Oct 22, 2007 IP