×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Extract the highest auto_increment numbered record

Extract the highest auto_increment numbered record

Extract the highest auto_increment numbered record

(OP)
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.

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']."'";

?>

RE: Extract the highest auto_increment numbered record

don't do it that way, use the LAST_INSERT_ID function instead

by the way, you should post your questions in forum436: MySQL AB: MySQL instead

smile

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close