kickoutbettman Posted May 17, 2009 Share Posted May 17, 2009 Hi, I'm just trying to figure out a way to go to a specific record. It's a golf stats system. So basically I have : $totalNumberOfGame I want to calculate some stats for all the games except the last one. So when I calculate let's say the average of all the shots with a specific club except from the last game . (it's to calculate the previous average before the last game) // There is also a 'idGame' in my holes table - I want to grab all the holes except the ones from the last game. $club = "PW"; $query_total_shots = "SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' "; $total_shots = mysql_query($query_total_shots, $golf_stats) or die(mysql_error()); $row_total_shots = mysql_fetch_array($total_shots); $totalRows_total_shots = mysql_num_rows($total_shots); So I just want to limit the numbers of row. I want to grab all the holes except the ones from the last game Hope it's clear enough. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/158494-solved-go-to-a-specific-record-mysql-php/ Share on other sites More sharing options...
kickstart Posted May 17, 2009 Share Posted May 17, 2009 Hi Just avoid the last one:- SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' AND GameDateTime != (SELECT MAX(GameDateTime) FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' ) This way you can use SQL numeric functions to work out the average. Or if you want to do it in php, this will bring all the rows back except the last one (issue being that I presume there are multiple holes per game):- SELECT * FROM holes WHERE idPlayer = '$idJPlayer' AND club = '$club' ORDER BY GameDateTime DESC LIMIT 1,18446744073709551615 All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/158494-solved-go-to-a-specific-record-mysql-php/#findComment-835903 Share on other sites More sharing options...
kickoutbettman Posted May 17, 2009 Author Share Posted May 17, 2009 Wow great, that work perfectly. Thanks fo this, i'm not so advance in SQL, but just enough to understand this. Thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/158494-solved-go-to-a-specific-record-mysql-php/#findComment-835911 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.