Forum Moderators: coopster

Message Too Old, No Replies

adding fields from A MYSQL querry

         

Sarah Atkinson

1:56 am on May 15, 2006 (gmt 0)

10+ Year Member



I have a field called quanity and I want to select several of them from the DB and then add them together. Is there a function that can do this for me or do I have to do it manualy with a while statment?
I think I remeber a function that did this or maybe it was just a function that added together all items in a string.

zCat

2:02 am on May 15, 2006 (gmt 0)

10+ Year Member



SUM() might be what you want:

SELECT sum(quantity) FROM table WHERE whatever

eelixduppy

2:07 am on May 15, 2006 (gmt 0)



This will help if i understand your post correctly: MySQL Aggregate Functions - SUM() [dev.mysql.com]

(the following was added after i posted)Late again! I really should type my reply in notepad and then come back and post it so im not posting something someone has already posted :)

eelix

[edited by: eelixduppy at 1:19 am (utc) on Jan. 22, 2008]

Sarah Atkinson

2:24 am on May 17, 2006 (gmt 0)

10+ Year Member



I got this to work. It actualy worked better then I had origionaly thought. By using the group by I was able to group it into the sum for the different id fields I wanted and therfore I only needed one sql instead of several.

Thank you