jaymc Posted February 6, 2007 Share Posted February 6, 2007 I have a member database and for each row in the database contains member information aswell as how many points a member has I want to do a query to see How many members have more points than them which will inevertably give me there rank out of all the members I was going to just structure a query to find all the members with > points than them and then use mysql_num_rows which would pick out there rank position But to do that Id first have to fetch there points so the entire operation will take 2 queries Anyway to squeeze this into one query and is it best using my method of mysql num rows.. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/37229-query-to-pull-member-member-points-together/ Share on other sites More sharing options...
artacus Posted February 6, 2007 Share Posted February 6, 2007 Sure, assuming your mysql server is current enough to do subqueries. Use the subquery to get the number of points that your user has. Then get all the users who have higher points in the outer query. Quote Link to comment https://forums.phpfreaks.com/topic/37229-query-to-pull-member-member-points-together/#findComment-177913 Share on other sites More sharing options...
fenway Posted February 6, 2007 Share Posted February 6, 2007 You could actually join in a derived "points" table, and dispense with the subquery all together. Quote Link to comment https://forums.phpfreaks.com/topic/37229-query-to-pull-member-member-points-together/#findComment-178150 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.