Why not just:

SELECT MAX(id) AS max_id FROM yourtable;

Then run another select to get the record?

Or, if you want the last record:

SELECT * FROM yourtable ORDER BY id DESC LIMIT 1;

maybe.

---------------------
Johnny Withers
[EMAIL PROTECTED]
p. 601.853.0211
c. 601.209.4985 

-----Original Message-----
From: Ian Moore [mailto:[EMAIL PROTECTED]] 
Sent: Friday, September 07, 2001 9:28 AM
To: Chris Bolt
Cc: [EMAIL PROTECTED]
Subject: Re: Select Highest ID query


On Thu, Sep 06, at 11:05pm, Chris Bolt ([EMAIL PROTECTED]) wrote:

> SELECT * FROM yourtable WHERE id = LAST_INSERT_ID();

But that will only work if it was the same thread that inserted the last
record in the table. If this is running from say .. a script that just
wants the last inserted record (highest ID) then it will not work
because LAST_INSERT_ID() will return 0.

-- Ian


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to