How can I count DB filed value ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Supper Baby
Forum Commoner
Posts: 27
Joined: Tue Aug 01, 2006 11:33 pm

How can I count DB filed value ?

Post by Supper Baby »

I've filed named Point

I want to count all the filed value ( the total value not the total filed number )

can I do it by using simple SQL query ? or should I do while statment to get it manually
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Please reword your question so that it makes some sence.

You have a file named 'Point'? Do you want to count all the lines in this file? Is there a database involved? Please clarify what it is you are trying to do.
Supper Baby
Forum Commoner
Posts: 27
Joined: Tue Aug 01, 2006 11:33 pm

Post by Supper Baby »

Code: Select all

id    point
1     10
2     10
3     10
4     5
5     10
I want to get the total number ( 45 )

:oops: Sorry for my poor english language
Supper Baby
Forum Commoner
Posts: 27
Joined: Tue Aug 01, 2006 11:33 pm

Post by Supper Baby »

:D I found the answer

Code: Select all

SELECT sum(point)
FROM yourtable;
:) thanks to MySQL Forum http://forums.mysql.com/read.php?10,113 ... msg-113110
Post Reply