0
我有一個遊戲,桌的樣子:在一個語句中從不同表中獲取數據?
// 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;
}
但有沒有辦法在一個select語句中做到這一點?
感謝