I have a query running on my database that seems to be really slow, so I'm sure I am taking the long way around on it. Hopefully someone can shed some light as to what I am doing wrong.
Tables are:
player_stats -> id,playerid,goals,assists,minutes,game_id,team_id,div_id,seasonid
players -> id,lname,fname,teamid,number,position
teams -> id,name,division
divisions -> id,name,seasonid
My query is this,
$stats_sql = "SELECT * FROM player_stats,teams,divisions,players WHERE player_stats.seasonid = '".$sid."' AND "
."player_stats.div_id = teams.division AND player_stats.div_id = divisions.id AND "
."teams.id = player_stats.team_id AND "
."players.id = player_stats.playerid AND players.position != 'G'";
Which is selecting about 8,000 entries and then I add up the goals and assists, and then run a function to sort the entries so I can get the top 25 point scorers.
Obviously I see that I shouldn't be selecting everything in all tables, but I'm sure it goes much deeper than that. I also am not sure if using joins will work better on what I am trying to do. ->NOOB<-
The final display is the players first and last name, division name, team name and the added goals and assists to equal points.
Thanks for your help...