I’m trying to pull

athleteid, firstname, lastname, rushyards, teamname


…while athletes.athleteid = ‘200’

My main goal besides getting this data out is that some athletes may move teams. So like atheleteid = ‘200’ may be on team 10 during weeks 1-4 but on team 15 for weeks 5-16. I’m trying to calculate the stats.rushyards for the entire team and since athleteid = ‘200’ got 20 yards from week 1-4 I want those stats to be reflected in team 10’s stats while his 80 yards during weeks 5-16 I want to be reflected for team 15’s data.


Table: athletes
Field: athleteid
Field: firstname
Field: lastname

Table: stats
Field: athleteid
Field: rushyards
Field: week

Table: tradelog
Field: athleteid
Field: teamid
Field: week

Table: teams
Field: teamid
Field: teamname


Any help is appreciated!

So show us your query, show us the results and what is the problem with it.
Besides there is a flaw in your table design.
If "rushyards" (whatever that means) is a function of athleteid and week, and teamid is a function of athleteid and week, too, these two (rushyards and teamid) should go into the same table stats. This also simplifies your query. With that design change there would be no more need for any athlete's data for calculating the team score - you could read it directly from stats grouped by teamid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.