itsureboy Posted October 25, 2009 Share Posted October 25, 2009 Okay, so what I'm trying to do is to calculate the number activities (rows) users have made in a table I call, lets say, ACTIVITIES in the last 24hrs. I then want to select the ID of the user that has had the most activity in the last 24hrs, however without selecting all of his activities and each of those rows information, because the table activities is mainly for the purpose of determining the most active user (by the amount of rows selected with his matching userid/ sort of a mode type thing) and select their userid based on that. Can anybody tell me a way or what I can use to accomplish this? Or it its even possible? I don't need help with any timing or anything like that, just a way. Hope this makes sense, kinda rushed through it, a little frustrated. Thanks ahead..... Quote Link to comment https://forums.phpfreaks.com/topic/178916-solved-php-mysql-help-calculate-most-active-user-based-on-num-of-matching-rows/ Share on other sites More sharing options...
VirtualOdin Posted October 25, 2009 Share Posted October 25, 2009 Try "count() where userid='[userid]' " Quote Link to comment https://forums.phpfreaks.com/topic/178916-solved-php-mysql-help-calculate-most-active-user-based-on-num-of-matching-rows/#findComment-943917 Share on other sites More sharing options...
itsureboy Posted October 25, 2009 Author Share Posted October 25, 2009 Thanks... But the problem with using that is that it will simply just count the rows of a specific user. I need to count the rows of all users and then select the id of the one with the highest count. Quote Link to comment https://forums.phpfreaks.com/topic/178916-solved-php-mysql-help-calculate-most-active-user-based-on-num-of-matching-rows/#findComment-943921 Share on other sites More sharing options...
trq Posted October 25, 2009 Share Posted October 25, 2009 I have asked for this question to be moved to our mysql help board. SELECT id, COUNT(id) AS cnt FROM users ORDER BY cnt DESC LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/178916-solved-php-mysql-help-calculate-most-active-user-based-on-num-of-matching-rows/#findComment-943924 Share on other sites More sharing options...
itsureboy Posted October 25, 2009 Author Share Posted October 25, 2009 Oh, sorry, didn't notice, I've been doing so much PHP its all i see.. But thanks, that looks like it'll work! let me test it out. thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/178916-solved-php-mysql-help-calculate-most-active-user-based-on-num-of-matching-rows/#findComment-943928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.