Jump to content

Recommended Posts

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.