Hi All:
I am in the midst of rewriting my site from ASP classic into PHP (MSSQL > MySQL) and may have painted myself into a corner with this problem. Hope the wisdom of this board could solve this!
I originally (MS SQL) had a table of athletes. It had their name, sport, playing status (retired, active etc.), 12 columns for up to 12 different teams they played on and individual columns for each type of award they may have won. So there was a HOF column, for example, and if this athlete was a Baseball HOFer it would say "Baseball" in this column for this athlete's record.
When rewriting the code to PHP I felt there was a better way to store this info. The problem with the old was that I was limited, especially in "teams", the number of options I can apply to any one athlete by the number of columns I had. I had 12 team columns, meaning I can use "NY Yankees" in team column "Team1", "Baltimore Orioles" in "Team2" and so on for "Reggie Jackson". But what about if an athlete was on more than 12 teams? Problem. Plus, the athlete table got very unwieldy with all these columns.
I thought I solved this problem by setting up a PlayerDetails table. This table would keep a separate record for each detail of the player and link to the Athlete table via the playerID hash. So now, there would be 2 separate records for the above example. One record would have "Reggie Jackson", the "Team" column would have "NY Yankees" and the playerID column would have his hash that matched the hash for "Reggie Jackson" in the Athlete table. I would have a second record the same as this with the exception of the team being "Baltimore Orioles". As Reggie was on 5 different teams and has 4 awards and records, there are a total of 9 records for "Reggie Jackson" all with the same playerID number linking this PlayerDetails table to the Athlete table.
Here is the FROM portion of my query to show you what I am doing:
PlayerDetails INNER JOIN ( Sports INNER JOIN ( Locations INNER JOIN ( Players INNER JOIN ( Promoters INNER JOIN Events ON Promoters.prID = Events.prID) ON Players.plID = Events.plID) ON Locations.loID = Events.loID) ON Sports.SportCode = Players.SportCode) ON PlayerDetails.plID = Players.plID
Now the problem...
As "Reggie Jackson" has 9 records in the PlayerDetails table, every time I search for "Reggie Jackson" his result is repeated 9 times. If I rewrite the FROM portion not to link PlayerDetails.plID = Players.plID everything is fine (with the exception that I cannot get results for "Team" or "Awards and Records" searches as expected). In hindsight, I see why this is happening. But I HOPE there is a way to remedy this without having to rewrite a TREMENDOUS amount of code!
Thanks!