UnknownPlayer Posted January 17, 2011 Share Posted January 17, 2011 I need help, i have table votes, and i wonna count all votes by same id and order them by most voted, can someone help me ? examplem i have in votes table these datas: id name_id 1 23 2 25 3 25 4 24 5 23 6 23 id is primary key, auto inc, and now i need to order it like this: 23 with 3 votes 25 with 2 votes 24 with 1 votes Can someone help me please? Link to comment https://forums.phpfreaks.com/topic/224769-order-by-count/ Share on other sites More sharing options...
Muddy_Funster Posted January 17, 2011 Share Posted January 17, 2011 your going to need to provide more details regarding the information that is in the table Link to comment https://forums.phpfreaks.com/topic/224769-order-by-count/#findComment-1161062 Share on other sites More sharing options...
UnknownPlayer Posted January 17, 2011 Author Share Posted January 17, 2011 U think, count for every name_id and to increse when do some action ? Link to comment https://forums.phpfreaks.com/topic/224769-order-by-count/#findComment-1161063 Share on other sites More sharing options...
Pikachu2000 Posted January 17, 2011 Share Posted January 17, 2011 I'm not 100% certain, but give this a try . . . SELECT `name_id`, COUNT(`name_id`) FROM `votes` GROUP BY `name_id` ORDER BY COUNT(`name_id`) DESC Link to comment https://forums.phpfreaks.com/topic/224769-order-by-count/#findComment-1161075 Share on other sites More sharing options...
UnknownPlayer Posted January 18, 2011 Author Share Posted January 18, 2011 Thanks.. Link to comment https://forums.phpfreaks.com/topic/224769-order-by-count/#findComment-1161321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.