2016-05-25 89 views
0

表: 玩家: ID(PK),名稱,隊,波什多個SELECT語句 - PHP + MySQL的

,對位: matchupID(PK),player1ID,player2ID
player1ID和2 FKs to Players.ID

我想選擇兩個球員的名字,但不能正確提取查詢。我不想在這裏工會。

有些事情,我也打開一個更好的建議來格式化我有兩個表。

$queryString = "SELECT Players.name FROM Players 
        INNER JOIN Matchup WHERE Players.ID = player1ID, 
        SELECT Players.name FROM Players 
        INNER JOIN Matchup WHERE Players.ID = player2ID"; 

回答

1

您shoudl加入兩個時間播放器,而不是對決

$queryString = "select a.name, b.name from Matchup as c 
      Inner Join Players as a on c.player1ID = a.ID 
      Inner Join Players as b on c.player2ID = b.ID";