Here is my current query that searches for a user entered player name.
$sql = "SELECT p.*, t.*
FROM players p, nflteams t, playerstats ps, positions pos
WHERE p.$search_sql_cat LIKE '%$search_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.$search_sql_cat ASC";
I almost get the results I want except for the team abbreviation.
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 year is in the playerstats table. Can anyone help me get on the right track here.