I was saying I need the username of every user_id I fetch, on top of the row I originally obtained. I can already do that with the MySQL queries I posted above. I'm now looking for a way to combine the queries so that I don't have to make 1+2*N queries. Instead just 1 query.
Modifying what you posted at the bottom might work. I will try some of that out. Thanks.
Edit: I can do it with one user id. Here's an example of where I need to output a table of ranks, and at the same time get the user name for every user_id.
SELECT $table_ranking.*, $table_user.name
FROM $table_ranking INNER JOIN $table_user
ON $table_ranking.user_id=$table_user.user_id AND $table_ranking.game_id=$game_id
The problem comes from extending this to get the usernames of both user_id1 and user_id2 for each row. It seems like I would need multiple joins to accomplish that. Maybe I can try screwing around with nested joins.