Jump to content


Photo

*SOLVED*Add the amount specified in a certain column of all rows in mysql?


  • Please log in to reply
2 replies to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 21 October 2006 - 02:43 AM

so I'm working on a hit counter, and basically each IP address gets its own row in the table, containing info about browser, platform, as well as their ip address and how many hits have come from that IP address. So for instance I may have a row with the column "hits" having the value "230" and on another row the value is "12". How would I write an SQL query to get all the results for my "hits" column and add them into a variable?

Thanks!
http://www.DaveLinger.com
dave at linger dot com

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 21 October 2006 - 02:52 AM

SELECT SUM(hits) AS total_hits FROM table

the MySQL manual has a whole host of functions to use.  check the manual.

#3 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 21 October 2006 - 03:02 AM

I checked it and couldn't find much of anything... thanks for the help; I'll check more closely next time.
http://www.DaveLinger.com
dave at linger dot com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users