Remo Posted November 1, 2009 Share Posted November 1, 2009 Dear all, I am struggling to write a query.. I have a table called image.. In that table users can store their favorite images. Fields are img_id, img_ext, post_dt and mem_id.. Here, i need to fetch which user uploads maximum images.. I need to retrieve mem_id and total no of images those were uploaded by the user.. I tried with Count() but i can't get.. So i need your help.. Kindly help me. Link to comment https://forums.phpfreaks.com/topic/179801-solved-need-to-query-to-get-highest-value-from-the-mysql-table/ Share on other sites More sharing options...
abazoskib Posted November 1, 2009 Share Posted November 1, 2009 Do you want to return the count for a certain user, or for all users all at once? Link to comment https://forums.phpfreaks.com/topic/179801-solved-need-to-query-to-get-highest-value-from-the-mysql-table/#findComment-948607 Share on other sites More sharing options...
Mchl Posted November 1, 2009 Share Posted November 1, 2009 For example: SELECT mem_id, COUNT(*) AS count FROM images GROUP BY mem_id OREDER BY count DESC LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/179801-solved-need-to-query-to-get-highest-value-from-the-mysql-table/#findComment-948655 Share on other sites More sharing options...
Remo Posted November 2, 2009 Author Share Posted November 2, 2009 SELECT mem_id, COUNT(*) AS count FROM images GROUP BY mem_id OREDER BY count DESC LIMIT 1 Thank you very much... It works well... Link to comment https://forums.phpfreaks.com/topic/179801-solved-need-to-query-to-get-highest-value-from-the-mysql-table/#findComment-949268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.