Porl123 Posted July 29, 2008 Share Posted July 29, 2008 I have a member's table with username, password, age, pet and DOB in and I'm trying to find the most popular pet. So I was wondering how I'd go about doing that. Any thoughts? Thanks for your help Link to comment https://forums.phpfreaks.com/topic/117157-using-count-in-queries/ Share on other sites More sharing options...
TempleDMDKrazd Posted July 29, 2008 Share Posted July 29, 2008 I have a member's table with username, password, age, pet and DOB in and I'm trying to find the most popular pet. So I was wondering how I'd go about doing that. Any thoughts? Thanks for your help assuming your table name is members SELECT pets, count(pets) FROM members GROUP BY pets ORDER BY count(pets) DESC the first row should contain the pet that is the most popular. Link to comment https://forums.phpfreaks.com/topic/117157-using-count-in-queries/#findComment-602592 Share on other sites More sharing options...
fenway Posted July 31, 2008 Share Posted July 31, 2008 the first row should contain the pet that is the most popular. Assuming there isn't a tie. Link to comment https://forums.phpfreaks.com/topic/117157-using-count-in-queries/#findComment-604636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.