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
>Chief Web Architect
>Accelerated Business Technologies, Inc.
Paul DuBois, paul@stripped