ajlisowski Posted May 16, 2011 Share Posted May 16, 2011 Hey all, I was wondering if there was a way to filter what row of data gets returned when using GROUP BY. For example, lets say I have two rows idnamevalue 1value 2 1Batman1015 2Batman2025 If I do SELECT * FROM `table` GROUP BY `name` how can I know which id, value 1 and value 2 I am going to get? I would like to be able to specify that I would want to get the results for the one with the highest value 2. Is that possible? So of an ORDER BY within the GROUP BY? Quote Link to comment https://forums.phpfreaks.com/topic/236535-group-by-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 16, 2011 Share Posted May 16, 2011 http://dev.mysql.com/doc/refman/5.1/en/example-maximum-column-group-row.html Quote Link to comment https://forums.phpfreaks.com/topic/236535-group-by-help/#findComment-1215989 Share on other sites More sharing options...
ajlisowski Posted May 16, 2011 Author Share Posted May 16, 2011 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236535-group-by-help/#findComment-1215997 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.