Page 1 of 1

add up a collum

Posted: Tue Jul 25, 2006 4:00 pm
by michael1991j
i cant figure out how to add all the data up on one row.
im using mysql and made a file uploading script it will upload and then record all the file that are uploaded
here is the sql
CHANGE `user` `user` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
CHANGE `filetype` `filetype` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
CHANGE `filesize` `filesize` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
CHANGE `filename` `filename` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
CHANGE `dateuploaded` `dateuploaded` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
now i want to set a limit for the 10mb for there file but i need to code that will add up all the file size on the columthat were uploaded so i can state they have the number of mb left

Posted: Tue Jul 25, 2006 4:05 pm
by jamiel
Is this MySQL?

Code: Select all

SELECT user, SUM(filesize) AS Total FROM user_table;

Posted: Tue Jul 25, 2006 4:05 pm
by feyd
the SUM() aggregate function can be used.