amadis Posted July 29, 2009 Share Posted July 29, 2009 Hey everyone, I've made a stat database for a softball team. I have all the information in but im having problems printing out some results. the way i have it set up is, a game table, player table and playerstats table. in the playerstats table, i have the game, player and a bunch of stats. I'm trying to print out the names of all the players on the roster and then use COUNT to find out how many games they appear in. when i use this query, it works for 1 predefined player (in the where clause) SELECT player.playerID,player.playerFirstName, player.playerLastName, COUNT(playerstats.playerID) FROM playerstats INNER JOIN player ON (playerstats.playerID=player.playerID) WHERE playerstats.playerID='1'; however, whenever i take out the where clause, it just prints out the first players name and then counts all the players appearences. IE) Ron Johnson has played 265 games. any ideas what the problem is? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/167915-solved-problem-printing-out-count-function/ Share on other sites More sharing options...
gassaz Posted July 29, 2009 Share Posted July 29, 2009 Try this.. SELECT player.playerID, player.playerFirstName, player.playerLastName, COUNT(playerstats.playerID) FROM playerstats INNER JOIN player ON (playerstats.playerID=player.playerID) GROUP BY playerstats.playerID; Quote Link to comment https://forums.phpfreaks.com/topic/167915-solved-problem-printing-out-count-function/#findComment-885900 Share on other sites More sharing options...
amadis Posted July 29, 2009 Author Share Posted July 29, 2009 Awesome! thanks so much!!! Quote Link to comment https://forums.phpfreaks.com/topic/167915-solved-problem-printing-out-count-function/#findComment-885964 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.