swordske Posted December 21, 2009 Share Posted December 21, 2009 i want to sum the steps together by users then arrange them by order then limit them to display top 3 highest score,but when i query this its not working may i know whats the problem in my query? $query2 = "SELECT SUM(steps) AS totalsteps FROM `userinput` WHERE userID = $i ORDER BY totalsteps ASC LIMIT 3"; Quote Link to comment https://forums.phpfreaks.com/topic/185899-problem-with-query/ Share on other sites More sharing options...
rajivgonsalves Posted December 21, 2009 Share Posted December 21, 2009 you forgot the group by $query2 = "SELECT SUM(steps) AS totalsteps FROM `userinput` WHERE userID = $i GROUP BY userID ORDER BY totalsteps ASC LIMIT 3"; Quote Link to comment https://forums.phpfreaks.com/topic/185899-problem-with-query/#findComment-981671 Share on other sites More sharing options...
swordske Posted December 21, 2009 Author Share Posted December 21, 2009 ty, it gets better now , but looks like the limit and and order by is still not working Quote Link to comment https://forums.phpfreaks.com/topic/185899-problem-with-query/#findComment-981677 Share on other sites More sharing options...
rajivgonsalves Posted December 21, 2009 Share Posted December 21, 2009 you'll have to show more of your code and whats not working, information like 1) What are the results 2) what were the expected results I feel the userID = $i is not need most probably your running it in a loop. Quote Link to comment https://forums.phpfreaks.com/topic/185899-problem-with-query/#findComment-981684 Share on other sites More sharing options...
swordske Posted December 22, 2009 Author Share Posted December 22, 2009 weee ty its working now i removed the userID= $i Quote Link to comment https://forums.phpfreaks.com/topic/185899-problem-with-query/#findComment-982008 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.