Link to home
Start Free TrialLog in
Avatar of intoxicated_curveball
intoxicated_curveball

asked on

Get all permutations of baseball players on a Team in SQL

Let's say I have 9 Tables: Catchers, Pitchers, Shortstops, First baseman, Second baseman, Third baseman, Left fielders, Right fielders, Centre fielders

Let's say each of these tables has 5 different 'Players' in it.

Now I want to get all possible team combinations (comprised of one of each position) into another table called 'Teams'

From my understanding of permutations there are 1,953,125 possible teams (5^9).

Any idea how could I create this 'Teams' table in SQL (I'm using MS Access by the way), there should be a column for each position?
Avatar of PatHartman
PatHartman
Flag of United States of America image

A Cartesian Product should produce the result you want.

Create a new query.  
Add all the tables to it.
Select the player from each table.
ASKER CERTIFIED SOLUTION
Avatar of Carl Bohman
Carl Bohman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Problem is, you are going to have players who play more than one position,so you are going to have to exclude all of those combinations as well.