Page 1 of 1

Possible to ADD the total number of 3.5 million rows?

Posted: Mon Apr 03, 2006 1:06 pm
by Deseree
one mysql db, one mysql table, 3.5 million rows of data, is it possible to add the entire column "used" WITHOUT LOOPING!!! lol, i don't want to transverse 3.5 million rows of data, so is there a mysql command to add all the 1's and 0's in the 'used' column quickly, efficiently, without overkill of mysql proccesses? lol.....

I know i'm asking for alot this christmas, but i've been a really good boy this year!!!!

lol...

Posted: Mon Apr 03, 2006 1:08 pm
by Deseree
looking into SUM() right now, hope this works...

Code: Select all

SUM(SELECT `used` FROM `table` WHERE `used` > 0)

COUNT(SELECT `used` FROM `table` WHERE `used` > 0)
Didn't work, any ideas?

Posted: Mon Apr 03, 2006 1:27 pm
by Deseree
SELECT SUM(`used`) FROM `table` WHERE `used`=1
Answered my own question :)

IT CAN BE DONE!!! Not sure if it's the most efficient way, but it works!