Hi
Can anyone help me to formulate this SQL query. I have a table with an auto_incremented field whenever a record is inserted. What I want to do is throw a record back at the user after it is inserted as a confirmation. Now I know that the said record must be the one with the highest number as it has just been inserted. So what I need to do is scan my table for the record with the highest (the field is called eventnum) number. I can pretty much write the select query myself but what is the code to just extract that one record with the highest eventnum number?
This is the code I'm currently using but I realised that this could bring up several records with the same venuename. I just what the latest record that was inserted based on the hifhest eventnum number.
Can anyone help me to formulate this SQL query. I have a table with an auto_incremented field whenever a record is inserted. What I want to do is throw a record back at the user after it is inserted as a confirmation. Now I know that the said record must be the one with the highest number as it has just been inserted. So what I need to do is scan my table for the record with the highest (the field is called eventnum) number. I can pretty much write the select query myself but what is the code to just extract that one record with the highest eventnum number?
This is the code I'm currently using but I realised that this could bring up several records with the same venuename. I just what the latest record that was inserted based on the hifhest eventnum number.
Code:
<?
$query = "select event_num, event_name, venue_name, streetaddress1, town, county, event_description, date_format(event_date, '%M %D, %Y ') as formatteddate, event_time from $table where venue_name = '".$_SESSION['venuename']."'";
?>