私はゲームを持っています、テーブルは次のようになります:
// users
user_id | favorite_color
// games
game_id | game_name
// game_participants
id | fk_game_id | fk_user_id
特定のゲームのすべてのユーザーのお気に入りの色を取得したい。私はこれを次のようないくつかのステップで行うことができます:
// get the game.
Game game = select * from games where game_id = 'abc';
// get each user's favorite color, one at a time.
for (participants in game) {
select favorite_color from users where user_id = game.participants[i].id;
}
しかし、1つのselectステートメントでこれを行う方法はありますか?
ありがとう