Skip to content
Advertisement

Which join or approach to use

I have two tables. First table contains names of individual teams and teamID which is PK. Second table contains details about matches: homeTeamID, awayTeamID, result.

I somehow need to combine these two tables in which I would have names (not IDs) of home and away team and the result of a match.

How to achieve this? First table looks like this:

Second table looks like this:

The resulting table needs to look like this:

Advertisement

Answer

You would typically join the teams table twice: once to get the name of the home team, another for the away team:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement