从玩家列表开始生成匹配列表

Generate list of matches starting from players list

我有以下情况:

Input data: 

Table t1:
+-------------+
| Teams       |
+-------------+
| India       |
| Australia   |
| England     |
| Italy       |
+-------------+

Required output:
+-------------+------------+
| Team1       |   Team2    |
+-------------+------------+
| India       | Australia  |
| India       | England    |
| India       | Italy      |
| Australia   | England    |
| Australia   | Italy      |
| England     | Italy      |
+-------------+------------+

即与哪个国家(Team2 列)比赛的国家(Team1 列)。

我尝试使用完全外部联接但无法获得不同的值。我们可以通过单个 sql 查询来实现吗?

"half"加入不平等的团队:

select a.team, b.team
from teams a
join teams b on a.team < b.team

live demo on SQLFiddle

只使用a.team < b.team而不是a.team != b.team returns 组合而不是排列 - 你只得到每个连接的一侧,只给你不同的组合。