Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
-
Contact:
Post
by itsmani1 »
I have table named votes and there is a field "cnt" in it where votes are casted. i want to count all votes against all entries? how can i do so?
thanks.
-
JayBird
- Admin
- Posts: 4524
- Joined: Wed Aug 13, 2003 7:02 am
- Location: York, UK
-
Contact:
Post
by JayBird »
Code: Select all
SELECT COUNT(`cnt`) as `total` FROM `votes` GROUP BY `cnt`
Something like that should do it without knowing your full table structure
-
itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
-
Contact:
Post
by itsmani1 »
its giving me all the vots, i need total not all votes.
-
jamiel
- Forum Contributor
- Posts: 276
- Joined: Wed Feb 22, 2006 5:17 am
- Location: London, United Kingdom
Post
by jamiel »
Code: Select all
SELECT SUM(`cnt`) as Total FROM `votes`
-
itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
-
Contact:
Post
by itsmani1 »
thanks much.