I have a mysql table for votes. there's an id
, a project_id
and a vote
field (which is 1 if a specific project is voted). now i want to generate a ranking from those entries. is there a way to get the number of votes for each project_id and automatically sort the entries by the number of TRUE votes of a project with a single mysql query? Or do you know a php way?
e.g.
ID | Project ID | Vote
-----------------------
1 | 2 | 1
2 | 2 | 1
3 | 1 | 1
==>
Project Nr. 2 has 2 Votes
Project Nr. 1 has 1 Vote
Thanks in advance!