Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding numbers in mysql

Status
Not open for further replies.

Silverfox2

Technical User
Oct 26, 2002
1
GB
Is it possible within a mysql query to add the contents of several feilds. I.E. If I had a table with days of the week and on each day there was an amount of hours entered into it. Is it possible to be able to run a query that adds up the total ammount of hours week so far. Can anyone help please
 
Something like

UPDATE tablename SET summation_field = hoursfield1 + hoursfield2 + hoursfield3

should do it. ______________________________________________________________________
TANSTAAFL!
 
if you jsut want to output it the rsult, SELECT sum(fieldname); should do , where fieldname would be the name of the field conatining the "hours".

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Oops, you're probably right KarveR.

I was thinking in terms of hours' being stored in columns, not in rows. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top