a2bardeals Posted June 12, 2006 Share Posted June 12, 2006 i am trying to create a top ten script for a MySQL ratings systemthe query works near perfectly but with one flaw. it wont put the damn things in order.it returns only ten of the highest rated.it groups the individual ratings from all cells where the article #'s are the same and averages them.but the ORDER BY doesn't seem to be working how i would like it to.query looks like this:mysql_query("SELECT article, AVG(rate) FROM ratings GROUP BY article ORDER BY rate DESC LIMIT 10");i belive my problem is in the order by becuase it doesn't order by the average rating and when i try:mysql_query("SELECT article, AVG(rate) FROM ratings GROUP BY article ORDER BY avg(rate) DESC LIMIT 10");i get errors.any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/11806-query-help/ Share on other sites More sharing options...
effigy Posted June 12, 2006 Share Posted June 12, 2006 Try: SELECT article, AVG(rate) [b]as rate[/b] FROM ratings GROUP BY article ORDER BY rate DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/11806-query-help/#findComment-44752 Share on other sites More sharing options...
a2bardeals Posted June 12, 2006 Author Share Posted June 12, 2006 thanks that worked perfectly...its always something small it seems Quote Link to comment https://forums.phpfreaks.com/topic/11806-query-help/#findComment-44773 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.