[Skip to the main content] Welcome to Daigo’s Daily Digital Diorama. I blog about Baseball, Judo, Jazz, Linux, Design and on being a dad.

  • Get Firefox!

SQL problem solved and I need to remember what I did…

As I ‘ve stated before, I’m switching from MySQL 4.1 to MySQL 5.0. I had a sql statement what used to work on 4.1 but stopped working and here is how I (and a little help from co-worker) fixed it:

SQL statement before (worked on 4.1 but gave error Query failed: Unknown column ‘player_info.team_id’ in ‘on clause in 5.0):

SELECT * FROM player_info, stats
JOIN teams ON player_info.team_id = teams.team_abbr
WHERE player_info.status = 1 AND stats.year = 2005
AND player_info.img_id = stats.img_id AND league_id = 1

ORDER BY player_info.team_id ASC

Fixed statement:

SELECT * FROM player_info, stats, teams
WHERE player_info.status = 1 AND stats.year = 2005
AND player_info.img_id = stats.img_id AND league_id = 1

AND player_info.team_id = teams.team_abbr
ORDER BY player_info.team_id ASC

I’m glad that it’s fixed!

Leave a Reply