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语句中做到这一点?
感谢