I am using a local MAMP connection and creating databases in phpMyadmin. I have a Fantasy Football Database that I want to return all combinations of a submitted lineup where the salary of the NFL players in the contest are less than or equal to a combined 50,000 AND the Fantasy Points Scored is greater than or equal to 200. So a valid lineup consists of a QB, RB1, RB2, WR1, WR2, WR3, TE, FLEX, and DST. A valid lineup can be only submitted if the combined cost of the 9 players in the lineup is less than or equal to 50,000 (for example, the QB costs 10,000, RB1 costs 5,000, RB2 costs 6,000 etc for all 9 slots which must be less than or equal to 50,000). Also, each lineup slot must have a unique player even though there are multiple Running Back and Wide Receiver slots. The FLEX slot can be either a RB, WR, or TE but again, it can't be any of the players in any of the other slots. I am trying to get the results of a contest and return a data set of all possible valid lineups that scored over 200. My database is NOT normalized. I do know how to normalize it and I can if it will make the results better/faster. But for now, I'm just trying to test the query. Here is a link to a sample data set https://docs.google.com/spreadsheets/d/1ECXtOj3MALgQNVMrr1wOlNso2iipqg2jzP6Ty9DZ0JA/edit?usp=sharing I have tried various SQL SELECT statements but they all freeze up and I can't get a result. I have tried limiting the number of results returned but to no avail. Here is basically the SELECT statement that I want to make:
SELECT DISTINCT QB, QB.Fpts, RB1, RB1.Fpts, RB2, RB2.Fpts, WR1, WR1.Fpts, WR2, WR2.Fpts, WR3, WR3.Fpts, TE, TE.Fpts, FLEX, FLEX.Fpts, DST, DST.Fpts
FROM QB, RB1, RB2, WR1, WR2, WR3, TE, FLEX, DST
WHERE
(QB.Salary + RB1.Salary + RB2.Salary + WR1.Salary + WR2.Salary + WR3.Salary + TE.Salary + FLEX.Salary + + DST.Salary <= 50000)
AND
(QB.Fpts + RB1.Fpts + RB2.Fpts + WR1.Fpts + WR2.Fpts + WR3.Fpts + TE.Fpts + FLEX.Fpts + DST.Fpts >= 200)
LIMIT 1000;
How can I make it where I can return values from this query and is there a way to save the results to a text file?