针对多个玩家的游戏数据库查询



我希望SQL结果如下(匹配结果查询(:

ID    Arena     Winner     Loser     Winner_score   Loser_score
-----------------------------------------------------------------
1       1       Johnny      Mark          16            8
2       2       Andrew      Luke          16            7  

这是我的表格(简化(

Player_tbl

ID    Player     
-------------
1     Johnny
2      Mark  
3     Andrew
4      Luke

Match_tbl

ID    Match     Arena    
----------------------
1     Match 1     1
2     Match 2     2

Match_results_tbl

ID    Match     player_id   player_score
-----------------------------------------
1     Match 1      1            16
2     Match 1      2             8
1     Match 2      3            16
2     Match 2      4             7

我想知道如何构建我的查询以获得所需的结果。

好吧,我解决了自己的问题。首先,match_results必须放在具有不同结构的表中,其次,需要调整内部sql查询以从正确的数据库表中提取。

最新更新