-2

I have table like below and Want to generate a round robin match schedule.

Input Table.

TID  PlayerID
2    14
2    1
2    21
2    37
2    17

Output 
14 V  1
14 V  21
14 V  37
14 V  17
1 V  21
1 V  37
1 V 17
21 V 37
21 V 17
37 V 17
Andrei Odegov
  • 2,925
  • 2
  • 15
  • 21
  • What determines the sequence order of values ​​in the `PlayerID` column? – Andrei Odegov Dec 10 '19 at 17:30
  • Does this answer your question? [Data structure for various tournament/competition types (league, ladder, single/double elimination etc.)](https://stackoverflow.com/questions/13564826/data-structure-for-various-tournament-competition-types-league-ladder-single) – Prune Dec 10 '19 at 17:59
  • If you search in your browser for "Round-robin match MySQL", you'll find references that can explain this much better than we can manage here. – Prune Dec 10 '19 at 18:00

1 Answers1

0

If you want all possible combinations regardless or left/right order you can do:

select
  a.player_id,
  b.player_id
from player a
join player b on b.player_id < a.player_id
The Impaler
  • 45,731
  • 9
  • 39
  • 76