add up a collum

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

add up a collum

Post 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
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Is this MySQL?

Code: Select all

SELECT user, SUM(filesize) AS Total FROM user_table;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the SUM() aggregate function can be used.
Post Reply