Code: Select all
FROM players p, nflteams t, playerstats ps, positions pos
WHERE p.lname LIKE '%$entered_term%'
AND ps.nflteam_id = t.nflteam_id
AND ps.player_id = p.player_id
AND p.position_id = pos.position_id
GROUP by p.player_id
ORDER BY p.lname ASC";If I search for a player with the last name of Moss, it returns:
Santana Moss NYJ
Randy Moss MIN
The teams that are returned are not the teams they currently play for. I want to find the team that they played for most recently. The teams shown above are the teams they first played for in their career. The years are in the playerstats table. I've tried several other variations, but just can't seem to get it right. Can anyone help me get on the right track here.