List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 25 2001 8:25pm
Subject:Re: LAST_INSERT_ID Issues
View as plain text  
At 9:48 AM -0400 5/25/01, Dave Carter wrote:
>This does not return any results

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
>Dave Carter
>Chief Web Architect
>Accelerated Business Technologies, Inc.
>grrrr sql,database

Paul DuBois, paul@stripped
LAST_INSERT_ID IssuesDave Carter25 May
  • Re: LAST_INSERT_ID IssuesPaul DuBois25 May
    • RE: LAST_INSERT_ID IssuesDave Carter25 May
RE: LAST_INSERT_ID IssuesGhislain Proulx25 May
RE: LAST_INSERT_ID IssuesDave Carter25 May
  • RE: LAST_INSERT_ID IssuesPaul DuBois25 May