0

Tables: Players: ID(PK), Name, Team, Pos

Matchups: matchupID(PK), player1ID, player2ID
player1ID and 2 are FKs to Players.ID

I'd like to select the name of both players when pulling but can't get the query correct. I do NOT want a union here.

Something along the lines of this, I'm also open to a better suggestion for formatting the two tables I have.

$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 Answer 1

1

You shoudl join two time Player and not matchup

  $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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.