I am trying to join two tables so that I can grab the information and order them by the members points. Here is the query I am trying to use:
Code:
$members_info = mysqli_query($connection, "
SELECT
team_member,
stage,
points
FROM team_member_scores
RIGHT JOIN team_members
ON team_members.team_id = team_member_scores.team_id
WHERE game_id = '".$game_id_info."'
AND team_member_scores.team_id = '".$team_id."'
GROUP BY team_member
ORDER BY points DESC
LIMIT 5")
or die(mysqli_error($connection));
This query pulls out all the team members correctly, but instead of grouping them and then ordering them by their points, it seem to just sum the points for all the members and lists that same summed number for every member. I need to pull out the info from both tables because I need to order them in a specific way, and not all team members will show up in the team_member_scores table if they didn't participate in the last game.
I would like to pull every match from the team members table that has the team id, regardless if they are in the team_member_scores table. I can get it to pull out the right information only from the team_members table. I can run two queries, but then I wont' get the sort order I am hoping for.
Anyway, if you need more info, please let me know. Any help and suggestions are greatly appreciated.