You are given a table Teams that contains the names of teams in a league.
Write a SQL query to report all the possible matches of the league.
Note: Every two teams play two matches with each other - one match where team A is the home team and team B is the away team, and another match where team B is the home team and team A is the away team.
Return the result table in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
team_name
PK
|
varchar | The name of the team (unique) |
Input & Output
| team_name |
|---|
| Arsenal |
| Chelsea |
| Liverpool |
| home_team | away_team |
|---|---|
| Arsenal | Chelsea |
| Arsenal | Liverpool |
| Chelsea | Arsenal |
| Chelsea | Liverpool |
| Liverpool | Arsenal |
| Liverpool | Chelsea |
With 3 teams, each team plays against the other 2 teams twice (once at home, once away). Arsenal vs Chelsea, Arsenal vs Liverpool, Chelsea vs Arsenal, Chelsea vs Liverpool, Liverpool vs Arsenal, and Liverpool vs Chelsea - totaling 6 matches.
| team_name |
|---|
| TeamA |
| TeamB |
| home_team | away_team |
|---|---|
| TeamA | TeamB |
| TeamB | TeamA |
With only 2 teams, there are exactly 2 matches: TeamA hosts TeamB, and TeamB hosts TeamA. Each team plays once at home and once away.
Constraints
-
1 ≤ number of teams ≤ 100 -
team_namecontains only letters and spaces - All team names are unique