If there is a possibilty of that then BEGIN INSERT ... whatever SELECT idno ORDER BY (idno) DESC LIMIT 1; END; It works, I just tried it in postgresql, the last idno is visible to the user making the transaction, and will be unavailable to others. From [EMAIL PROTECTED] Wed Sep 18 22:34:13 2002 Envelope-to: bob@localhost Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: <mailto:[EMAIL PROTECTED]> list-unsubscribe: <mailto:[EMAIL PROTECTED]> list-post: <mailto:[EMAIL PROTECTED]> Delivered-To: mailing list [EMAIL PROTECTED] From: Jon Haworth <[EMAIL PROTECTED]> To: 'bob parker' <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Date: Wed, 18 Sep 2002 13:27:56 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" Subject: RE: [PHP] Auto-increment value X-UIDL: *ab"!\-5!!-$7!!nk~!!
Hi Bob, > SELECT idno ORDER BY idno DESC LIMIT 1; > assuming idno is what gets auto incremented That's not the best idea - what happens if two users are inserting records into the table at nearly-but-not-quite the same time? 1. Insert A goes through 2. Insert B goes through 3. LastID A returns the ID of B 4. LastID B returns the ID of B Whoever did insert A would receive the wrong ID. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php