At 9:48 AM -0400 5/25/01, Dave Carter wrote:
>This does not return any results
>
>SELECT LAST_INSERT_ID() FROM tablename;

It doesn't return *any* results? Or do you mean it returns 0?


FROM tablename is superfluous here; the most recent AUTO_INCREMENT value
is maintained on a per-connection basis. This means that if you want to
use this value, you must:
- Issue some statement (e.g., INSERT) that causes an AUTO_INCREMENT value
   to be generated, and
- You must select the value of LAST_INSERT_ID() within the *same* session.

If you issue the INSERT, then disconnect, reconnect, and retrieve the value
of LAST_INSERT_ID(), it won't work (you'll get zero), because that involves
two sessions with the server, not one.

>
>there is an indexed, auto-incrementing field in the table, but it refuses to
>show any results. I don't understand the manual's text, so any help would be
>appreciated.
>
>
>Dave Carter
>Chief Web Architect
>Accelerated Business Technologies, Inc.
>http://www.abti.cc
>717.464.2970
>
>grrrr sql,database


-- 
Paul DuBois, [EMAIL PROTECTED]

---------------------------------------------------------------------
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