blooddrainer Posted September 29, 2008 Share Posted September 29, 2008 Hello all, i have some problem. I have field id, rating, category. Rating content integer, category varchar, id (autoincrement). I want to make query that get 6 result from the table with biggest rating. I have some query but there is some bug. Here it is: SELECT `gid`, AVG(`rating`),`cat` FROM `games_rating` group by `gid` having `cat`='trailers' order by AVG(`rating`) desc limit 0,6 Quote Link to comment https://forums.phpfreaks.com/topic/126234-solved-help-for-mysql-query/ Share on other sites More sharing options...
Barand Posted September 29, 2008 Share Posted September 29, 2008 try this (I left out "cat" as you know that will be "trailers") SELECT gid, AVG(rating) as avrate FROM games_rating WHERE cat = 'trailers' GROUP BY gid ORDER BY avrate DESC LIMIT 6 Quote Link to comment https://forums.phpfreaks.com/topic/126234-solved-help-for-mysql-query/#findComment-653198 Share on other sites More sharing options...
blooddrainer Posted October 1, 2008 Author Share Posted October 1, 2008 THANKS It works Quote Link to comment https://forums.phpfreaks.com/topic/126234-solved-help-for-mysql-query/#findComment-654503 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.